Re: Problem cancelling lengthy task in secondary thread
Re: Problem cancelling lengthy task in secondary thread
- Subject: Re: Problem cancelling lengthy task in secondary thread
- From: "Alastair J.Houghton" <email@hidden>
- Date: Thu, 30 Oct 2003 14:22:03 +0000
On Thursday, October 30, 2003, at 01:53 pm, Jvrn Salewski wrote:
I tried out braces in despair, but it didn't change anything.
I was also NSLoging the _continue variable, but it's not changed until
the
inner loops are done; it's apparently not a problem of checking for its
value, but setting it.
I think I may just have spotted the problem. I had assumed that you
were just setting _continue from the main thread, but you aren't...
you're using DO to call your object, right? Well, I think you'll find
that DO relies on the run-loop. Presumably _TOCAuthor and/or _TOCWork
are passed-in via DO from your main thread? If they are, then invoking
methods on them will cause event processing to occur whilst the DO
proxy object waits for a reply... and because events are being
processed, the call to -setContinueSearch: can be triggered at that
point. -setContinueSearch can't be triggered during the inner loops,
because there is no event processing going on.
To see what I mean, add some NSLog() calls, one in -setContinueSearch,
one just after the "if (! _continue) break;" statement, and one before
"int error = 0". I think you'll find that -setContinueSearch is
*always* executed between those two lines, and never in any other place.
You'll probably also find that calling *any* (non-oneway) method on an
object provided by the main thread within your inner loops will make
your program work.
Kind regards,
Alastair.
_______________________________________________
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.