• 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: Catching a click during a loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching a click during a loop


  • Subject: Re: Catching a click during a loop
  • From: Carlos Salinas <email@hidden>
  • Date: Sat, 30 Jul 2005 20:13:40 -0700

I have a program with a rather lengthy process, and I would like to be able to click cancel and have the operation canceled. This process is preformed within a while loop. I have tried running it in a new thread, I have tried the runUntilDate and neither seems to allow my cancel button to be clicked (You click and nothing happens.)

If your process is executing in a while loop on the main thread, then you are blocking the run loop and events are not dispatched. You might be able to fetch the events and dispatch them yourself, but a better solution would be to run the process in a separate thread. The button click would caused a method to be executed on the main thread. That method could signal a stop on the second thread (perhaps via an NSConditionLock). The process thread would periodically check the lock and stop execution when it changes.
_______________________________________________
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: 
 >Catching a click during a loop (From: Mark Williams <email@hidden>)
 >Re: Catching a click during a loop (From: Cameron Hayne <email@hidden>)
 >Re: Catching a click during a loop (From: Mark Williams <email@hidden>)
 >Re: Catching a click during a loop (From: Mark Williams <email@hidden>)

  • Prev by Date: NSNumberFormatter scientific notation
  • Next by Date: Re: Catching a click during a loop
  • Previous by thread: Re: Catching a click during a loop
  • Next by thread: Re: Catching a click during a loop
  • Index(es):
    • Date
    • Thread