• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting a user click while in a lengthy task (mainthread)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Detecting a user click while in a lengthy task (mainthread) (From: Aurélien Hugelé <email@hidden>)

  • Prev by Date: Detecting a user click while in a lengthy task (mainthread)
  • Next by Date: LDAP and Cocoa
  • Previous by thread: Detecting a user click while in a lengthy task (mainthread)
  • Next by thread: Re: Detecting a user click while in a lengthy task (mainthread)
  • Index(es):
    • Date
    • Thread