Re: NSThread sleepUntilDate
Re: NSThread sleepUntilDate
- Subject: Re: NSThread sleepUntilDate
- From: Shawn Erickson <email@hidden>
- Date: Sat, 10 Jul 2004 12:40:02 -0700
On Jul 10, 2004, at 10:02 AM, David Blanton wrote:
I want to do some stuff then wait for an interval (20 seconds) before
doing
the next instruction. Is sleepUntilDate the way to do this?
NSDate * d = [NSDate dateWithTimeIntervalSinceNow:20]
NSThread * t = [NSThread currentThread];
[t sleepUntilDate:d]
I usually prefer to chain them together...
[[NSThread currentThread] sleepUnitDate:[NSDate
dateWithTimeIntervalSinceNow:20]];
Of course doing this in your main thread will stall event processing
while the threads sleeps. It is better to do this in a secondary thread
or use an NSTimer instead or some type of callback/event depending on
why you want to delay things.
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.