Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSApp runModalSession] from Carbon app





Could I ask you how you create your thread? I'm using multi- threading with modal window without any issues.
The only issues with runModal i know is that by default, the modal run loop handle only a small subset of run loop sources that does not include network sources for example (so NSURLDownload will not process wil a modal window is running).
But with a multi-threaded application, this is not a problem as each thread has is own runloop and should no be affected by other thread activity.



As I said, it is a cooperative thread, not a preemptive thread. It is created with

NewThread(kCooperativeThread, ...

The preemptive threads created with MP... work fine

Kurt


Sorry for my missunderstanding. I didn't even know that cooperative threading was available on OS X.

I have just try to use them in a simple Cocoa project, and I cannot reproduce your problem.

I have a main method I call in an IBAction method:

- (IBAction)testModal:(id)sender {
NSModaleSession session = [NSApp beginModalSessionForWindow:uiWindow];
while ([NSApp runModalSession:session] == NSRunContinuesResponse) {
printf("one modal loop\n");
YieldToAnyThread();
}
[NSApp endModalSession:session];
}


and a cooperative thread that do this:

static voidPtr _ThreadEntryProc(void * threadParam) {
  while (true) {
    printf("one loop\n");
    sleep(1);
    YieldToAnyThread();
  }
  return NULL;
}

and the output is as expected:

one modal loop
one loop
one modal loop
one loop
one modal loop
one loop
...


_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >[NSApp runModalSession] from Carbon app (From: Kurt Sutter <email@hidden>)
 >Re: [NSApp runModalSession] from Carbon app (From: Jean-Daniel Dupas <email@hidden>)
 >Re: [NSApp runModalSession] from Carbon app (From: Kurt Sutter <email@hidden>)
 >Re: [NSApp runModalSession] from Carbon app (From: Jean-Daniel Dupas <email@hidden>)
 >Re: [NSApp runModalSession] from Carbon app (From: Kurt Sutter <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.