Since you can postpone the task midstride, then you might just want to think of this in terms of breaking the task up into small pieces to be interspersed with event handling.

- (void)doSomeMoreWork
{
    [self doTheNextStep];

    if([self isMoreWorkToDo])
[self performSelector:@selector(doSomeMoreWork) withObject:nil afterDelay:0.0];
}

If your work units are small enough, you shouldn't really have to worry about idleness.


On Oct 27, 2008, at 6:19 AM, Oleg Krupnov wrote:

Yes, I'd really like to avoid multi-threading. There would be an
intense data exchange between the threads and the effort for
synchronization would be simply not justified for such a tiny feature.
Actually I did try multi-threading before I arrived to this solution,
and I have spent very long and painful day debugging some weird
rare-happening synchronization bug. Besides, real multi-threaded task
works slightly different than simply postponed-to-idleness task. The
two threads may be running simultaneously even if the main thread has
a higher priority, whereas I'd prefer strict suspension of the
secondary task when the main thread wakes up.


On Mon, Oct 27, 2008 at 3:05 PM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:

Le 27 oct. 08 à 13:54, Oleg Krupnov a écrit :

In my app I'd like to perform some background task without affecting
the responsiveness of the UI. To avoid multi-threading, I just
postpone the task to a moment when the user becomes and stays idle for
a certain time.


Have you a good reason to avoid multi-threading ?


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/psagers %40ignorare.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to