 |
 |
Sequential Tasks
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
Hello,
I am running into problems when trying to execute several NSTasks one at a time. Essentially I need each task to wait for its predecessor to terminate before launching. I have tried to use a notification (TaskDidTerminate) that sets a finished flag partnered with a thread-stalling loop between each task but it doesn't work (I think that the sleepUntilDate call is even blocking the Notification).
Is there any simple way to do this is or will I have to do something similar to what I am doing now just with the Notification occurring in a different thread? Which also brings me to my next question: How can I specify which Thread a Notification response is launched into? Is it the same thread as the one who registered the observer?
Thanks in advance,
Jeff.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
Shortly after posting this I did find the "waitUntilExit" method of NSTask. I have been trying to use it but it is not fixing any of my problems. Does anyone know if leaving an un-emptied NSPipe and its associated NSFileHandle will cease to allow the task to properly exit?
Jeff.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
Shortly after posting this I did find the "waitUntilExit" method of NSTask. I have been trying to use it but it is not fixing any of my problems. Does anyone know if leaving an un-emptied NSPipe and its associated NSFileHandle will cease to allow the task to properly exit?
Jeff.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Note that you can only use each NSTask instance once. And notifications are received in the same thread that they are posted, I thin, and you can't make them occur in other threads.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
I read something in the Apple Developer documentation recently that said you can only call an NSTask once and that any subsequent calls will produce an error. Does anyone know if this means you can only call one instance once in each launch of your program or does it means something about having to release and re-instantiate the task each time?
If I can only use one task once, I guess I will have to find a different way of running sub-programs. Does anyone know if the security framework will let you launch a program without security and then go on to launch several tasks?
Thanks for any help,
Jeff.
[ 08-15-2001: Message edited by: Apocalypse ]
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by Apocalypse:
<STRONG>If I can only use one task once, I guess I will have to find a different way of running sub-programs. Does anyone know if the security framework will let you launch a program without security and then go on to launch several tasks?</STRONG>
What the documentation actually says is:
An NSTask can only be run once. Subsequent attempts to run an NSTask will raise an error.
You can definitely create more than one instance of an NSTask, otherwise what would the point of NSPipe be?
Security.framework is for authorization, nothing else. There are POSIX APIs for executing other processes should you need them, but NSTask is fine.
If you had played around before asking, you would easily find this to be the case.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
I have played around with it but I am still getting problems trying to run multiple sequential tasks. It seems as though the first task locks the file so the second task doesn't want to use it. Does anyone know why this problem could be happening?
Jeff.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
Well, I found an application I wrote a few months back which does allow sequential calls to NSTask objects so I know that can't be the problem. Still, though, after days (several hours each day for the past 3) I still can't fix the problem. I even set my program to wait for a button to be clicked between each call and still I get this problem.
More about the problem:
I call one task that creates a file.
When the second task launches to work with the file, I get a crash claiming that the file is still in use.
Can anyone think of anything?
Thanks,
Jeff.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|