[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] SWT and network / socket data?
|
- From: Sal Valente <svalente@xxxxxxx>
- Date: Tue, 06 Dec 2005 00:39:12 -0500
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)
I have an SWT program that displays a Label. Whenever the user selects a
menu item, I want to display something in that label. Also, the program
is listening for data on a Socket. Whenever network data arrives, I want
to display it in the Label.
So I've got two Threads. One is running the SWT main loop:
while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();
The other is reading and processing data from the network socket.
I don't think it's a good idea (or at all legal) for the second
Thread to ever call label.setText(). I want to funnel all SWT calls
through a single thread. Is there a way to do this, or, better
yet, is there a "right" way to do this? (Is there a way for the network
thread to add events to the end of the queue so that the SWT thread will
get to them in their turn? Or a way for the network thread to
wake-up the SWT thread?)
Thanks.