[Gtk-sharp-list] Help me with Invoke in Gtk

White Spirit wspirit at homechoice.co.uk
Mon Dec 18 17:50:11 EST 2006

Duong Nguyen wrote:

 > Hello, Help me with  Invoke  in Gtk.

 > I have custom EventArgs and EventHandler


 > And I have a class ChatClient (the class must be designed to work with
 > every interface-platform, so I can not put the chat-message directly to
 > any Gtk Control like TextView or Entry inside the class, instead, I must
 > write some custom Event, which will be fired each time my ChatClient
 > receives message). And here is some code from class ChatClient


 > Of course, this Code is written in C# + WinForm. I can not find the
 > similar thing in Gtk, pls help me with this problem!
 > Thanks in advance!

I recently did something very similar.  I used a separate thread to 
receive messages and then called Application.Invoke so that the thread 
could safely place the received text in a TextView buffer.

Instead of using an event, the thread that receives message text simply 
receives data from a socket and when a line has been entered, 
Application.Invoke is called.  If you're using UDP rather than TCP, it 
would be very similar.  The text buffer has global scope so that it can 
be accessed from within the thread.

I hope that helps.

More information about the Gtk-sharp-list mailing list