Re: threads vs run-loops for keeping your GUI responsive
Re: threads vs run-loops for keeping your GUI responsive
- Subject: Re: threads vs run-loops for keeping your GUI responsive
- From: Markus Hitter <email@hidden>
- Date: Fri, 9 Dec 2005 18:31:04 +0100
Am 09.12.2005 um 18:05 schrieb Joshua D. Orr:
On Dec 9, 2005, at 7:44 AM, Niko Matsakis wrote:
Unfortunately, it is not clear to me how I might schedule a call
to this event. I have scoured the wiki and mailing list, but I
can't find much mention of this approach: everyone seems to want
to create worker threads.
I know I could use NSTimer, but again that doesn't feel quite
right: I want the function to be called ASAP, assuming that
nothing else is going on; scheduling it for a certain time seems
overly complicated.
Surely there is a way to do this? Am I missing something? Is
this not a good approach?
[[NSRunLoop currentRunLoop] performSelector:@selector(someMethod)
target:sombObject
argument:nil
order:6
modes:[NSArray arrayWithObject:@"NSDefaultRunLoopMode"]];
'order' defines the priority incase there are more then one events
to process.
I accutaly used this method in a run loop running in a separate
thread (not the main thread) and it worked great. I am sure it
would work fine in the main thread.
Anyway, This will tell the run loop to execute the method next time
execution reaches the run loop.
... and other events get inserted as they come in between. I've used
this approach in the main loop and it works as expexted.
Still I doubt you gain anything since you still have to split your
processing into chunks which usually involves some overhead (storing
the current state away, resuming a millisecond later etc.).
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