Tima wrote:

Hi,

I'm trying to make a client-server application in GNUstep.
Right now it seems that the best way to do the client is to
make it a two-threaded application, with a main thread processing
GUI events and a "worker" thread waiting and reading messages
from socket-related NSInputStream.

I want the worker thread to notify the main one when the message is ready.
After reading Apple documentation for some time I got an impression
that I need to send message to main thread's NSPort, it will be delivered
via -handlePortMessage: method of the port's delegate.

First of all, is it really the intended way to do communication
between threads?

If all you want is to notify your main thread that data is available
(and the data itself is passed through some shared data structure), you
might want to have a look at NSObject's
  -performSelectorOnMainThread:withObject:waitUntilDone:
method. Something along
  [[NSNotificationCenter defaultCenter]
   performSelectorOnMainThread:@selector(postNotification:)
                    withObject:notification
                 waitUntilDone:YES];
probably is what you want to do.

Regards
Wolfgang



_______________________________________________
Help-gnustep mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnustep

Reply via email to