On 14/07/2009, at 10:33 PM, Thomas Pesters wrote:

Hi,

I'm having the following problem:

- I'm opening a panel with a progress indicator
- I'm starting a new thread with a background function (via NSThread
detachNewThreadSelector)
- I do NSApp runModalForWindow: for the progress panel
- when the thread is finished, I close the progress panel ("orderOut:self")
and do [NSApp abortModal];

When my app finishes the background thread, the progress window closes as expected, modal stops and the windows below get focus. But: only after an event arrives (moving the mouse or hitting a key), the normal procedure of the app continues (in my case an alert is supposed to open to show some result of the just finished background processing, which does not open until
an event arrived).

What am I doing wrong?


When your thread updates the progress window, it needs to ensure that this happens on the main thread, so at some point the progress notifications need to call -performSelectorOnMainThread:, etc..

Also, may I ask: if you run the progress window modally, your app is effectively blocked, as far as the user's ability to get work done is concerned. This to my mind means that doing the work in a background thread is of no benefit - you may as well have run that code synchronously. In the few places I do this sort of thing, my progress window is modeless so that the user can do stuff while the background thread runs, and just keep an eye on how it's going with the progress window. Wouldn't that make more sense?

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to