• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: stop a lengthy task in a thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stop a lengthy task in a thread


  • Subject: Re: stop a lengthy task in a thread
  • From: Dave Camp <email@hidden>
  • Date: Tue, 18 May 2004 15:38:18 -0700

On May 18, 2004, at 2:32 PM, Morphine wrote:

Hello,

I don't found how to stop a lengthy task in a thread !!!
Here, what I have do :

IN THE THREAD :
- (void oneway) calcul { // this method is called by the main application
NSDirectoryEnumerator *enumDirectories = [fileManager enumeratorAtPath:@"/"] ;
while (file = [enumDirectories nextObject]) {
if (stop) break ; // stop is declared in header file as BOOL
// a task...
}
}
- (void oneway) pleaseStop { // this method is called by the main application
NSLock *lock = [[NSLock alloc] init] ;
[lock lock] ;
stop = YES ;
[lock unlock] ;
}

How to do for set the "stop" bool to change it's state ???

You don't mention it, but your code suggests you are using Distributed Objects to communicate between threads. Based on that, I'm going to guess the call to pleaseStop is scheduled on the runloop for calcul() but is never run because calcul() is in a tight loop and not processing mach messages.

You either need to make the call to pleaseStop not use DO (i.e. execute on the caller's thread, or somehow make it execute on a different thread than calcul().

Dave

---
In English, every word can be verbed.
_______________________________________________
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.


  • Follow-Ups:
    • Re: stop a lengthy task in a thread
      • From: Morphine <email@hidden>
References: 
 >stop a lengthy task in a thread (From: Morphine <email@hidden>)

  • Prev by Date: Re: developing a cross-platform app?
  • Next by Date: Re: disk:// and help:// security problems
  • Previous by thread: stop a lengthy task in a thread
  • Next by thread: Re: stop a lengthy task in a thread
  • Index(es):
    • Date
    • Thread