Call invoke on main thread?


#1

Hey all,

I’m creating a browserplugin with juce. In the plugin, i create a class which is a subclass of Thread. In my thread class, i want to call some method in javascript (for now, it shows an alert). This is not a problem when i do it in the main thread. However, when i execute the same code from my thread, it wont show the alert. So my guess is that i have to somehow execute this on the main thread. However, the Thread class does not have some mechanism to do this.

Any ideas?

The code to call javascript:

....
	var m_jsCallbackObject; // this is set from the main thread
....


	var params[] = {
		error, userdata, -1, localfile, fileID, httpstatuscode
	};
	m_jsCallbackObject.invoke("FireOnDownload", params, 6);

#2

Use a CallbackMessage or AsyncUpdater, or MessageManager::callFunctionOnMessageThread.


#3

Thanks, that worked :slight_smile: