Re: Cocoa idiom for time consuming tasks
Re: Cocoa idiom for time consuming tasks
- Subject: Re: Cocoa idiom for time consuming tasks
- From: "Mike Davis" <email@hidden>
- Date: Mon, 4 Feb 2002 00:46:46 -0500
In Only Mortal and in ViaVoice I push long tasks into a thread using the
command pattern. For stopping the commands in the queue, I remove the
waiting commands and "cancel" the current command. I use cancelable threads.
To call back to the main thread, from the command, I use a NSConnection. The
docs for NSConnection have an example, though you'll need to do some more to
make it useful in a real application. Add in a timeout on the connection,
both ends, and exception handling.