[Gtk-sharp-list] Application.Invoke

Felipe Almeida Lessa felipe.lessa at gmail.com
Tue Jan 9 08:04:10 EST 2007


On 1/9/07, Robert Schillinger <robby.schillinger at t-online.de> wrote:
> the invoked delegates are only executed when some keystrokes or mousemoves
> are done.

I had a similar problem, too. To workaround it, I added a timeout that
forces the execution just like mouse movement and other events do.
Here's a snippet

	// Request updates
	Thread t = new Thread(delegate () {
		UpdateManager.CheckForUpdates();
	});
	t.Start();
	
	// This will generate events so that RunIteration doesn't block forever
	GLib.Timeout.Add(25, delegate {
		return t.IsAlive;
	});

The timeout will force the Invoke to be done with 25 ms of delay at
maximum, which is acceptable, and without any CPU harm. When the
thread exits, t.IsAlive is false and the timeout is gone. Works like a
charm.

Good luck,

-- 
Felipe.


More information about the Gtk-sharp-list mailing list