Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching a click during a loop



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden


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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.