Sending an event from another thread

  • Hi,

    I need to send a message from one thread to another, but I'd like to
    put it in the standard event queue of the NSApp. My main thread is
    running it's own message loop (nextEventMatchingMask....), and the
    other thread needs to send it a message that it needs to do something
    (open a window). I would like best if I could put a custom NSEvent of
    some sort into the queue so that the main thread receives it along
    with other events. Is this possible, and where should I look for info?
    If not, what would be the best way to do it?

    Thanks,
    Ivan
  • On Jan 4, 2008, at 5:20 PM, Ivan Galic wrote:

    > I need to send a message from one thread to another, but I'd like to
    > put it in the standard event queue of the NSApp. My main thread is
    > running it's own message loop (nextEventMatchingMask....), and the
    > other thread needs to send it a message that it needs to do
    > something (open a window). I would like best if I could put a custom
    > NSEvent of some sort into the queue so that the main thread receives
    > it along with other events. Is this possible, and where should I
    > look for info? If not, what would be the best way to do it?

    Use the -performSelectorOnMainThread:... methods in NSObject. You
    don't need to use NSEvent to open a window; just send it the message
    on the main thread to open.

    Nick Zitzmann
    <http://www.chronosnet.com/>
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today