Re: Detecting a user click while in a lengthy task (mainthread)
Re: Detecting a user click while in a lengthy task (mainthread)
- Subject: Re: Detecting a user click while in a lengthy task (mainthread)
- From: Markus Hitter <email@hidden>
- Date: Fri, 13 Jan 2006 11:11:59 +0100
Am 13.01.2006 um 10:28 schrieb Aurélien Hugelé:
I need to offer the user to cancel a lengthy blocking task (suppose
it can not be threaded, and thus runs in the mainthread).
basically something like while(!cancelled) { // do something }.
The problem here is that the action of my cancel button is not
called because the UI is hanged by the task.
You can split your calculation into small chunks. At the end of each
chunk insert an event into the run loop to resume calculation (-
NSRunloop performSelector). If there are other events, like mouse
clicks, they will sit in the run loop's queue before your resume
event and will be handled first. To cancel the calculation, remove
the resume event (-NSRunloop cancelPerformSelector).
Markus
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden