Skip navigation.
 
mlRe: Self terminating popup window - need help
FROM : Joshua Orr
DATE : Fri Apr 15 18:55:01 2005

Thatıs because the run loop is still running, I think.  When you close the
window, you might want to try stoping the run loop.

Look up NSRunLoop  in apples developer documention.

Instead of uisng 'run'  you could use:

runUntilDate:(NSDate *)date

And provide a NSDate of when the runloop should stop.

> It works the first time it is done, but after the window closes the
> execution does not return where it left off, and my program is
> unresponsive.
>
>
>
> On 4/14/05, Jagil Dragon <<email_removed>> wrote:

>> I have never needed to run a timer in a thread other then the main thread
>> (which automatically has a run loop). In the method your new thead executes,
>> what you can try is this:
>>
>> NSPool *pool = [[NSAutoreleasePool alloc] init];
>> NSRunLoop *runLoop;
>> runLoop = [NSRunLoop currentRunLoop];
>> // Make your timer in here...
>> [runLoop run];
>> [pool release];
>>
>> Let me know if that does not work, because I have another idea that might.
>>
>>
>> Quoting Dan Yocom <dan.yocom.<email_removed>>:

>>> Is there a way to let my thread have a message run loop?
>>>
>>> On 4/14/05, Joshua D. Orr <<email_removed>> wrote:

>>>> I am guessing you are using a NSTimer.  Your new thread probably
>>>> does not have
>>>> a message run loop running, and NSTimer makes use of that.
>>>>
>>>> Quoting Dan Yocom <dan.yocom.<email_removed>>:
>>>>

>>>>> Hi,
>>>>>  I created a subclass of NSWindow that automatically closes the
>>>>> window after three seconds. The subclass works as it should when
>>>>> called from a normal objective-C routine/function. However, if I call
>>>>> it from within a NSThread I create, it will popup but not close. Does
>>>>> anyone know why it won't work porpperly when call from within an
>>>>> NSThread?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------- Custom NSWindow class
>>>>> --------------------------------
>>>>>
>>>>> - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned
>>>>> int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
>>>>> {
>>>>>
>>>>>      NSWindow* result = [super initWithContentRect:contentRect
>>>>> styleMask:aStyle backing:NSBackingStoreBuffered defer:NO];
>>>>>    [result setLevel: NSStatusWindowLevel];
>>>>>
>>>>>    [self performSelector:@selector(closeSplashScreenPanel)
>>>>> withObject:nil afterDelay:3];
>>>>>
>>>>>    return result;
>>>>> }
>>>>>
>>>>> - (void)closeSplashScreenPanel
>>>>> {
>>>>> [self release];
>>>>> }
>>>>>
>>>>> ---------------------------------- NSThread Stuff
>>>>> ---------------------------------------------
>>>>> [NSThread detachNewThreadSelector: @selector(MyThread) toTarget:self
>>>>> withObject:nil];
>>>>>
>>>>> - (void)MyThread
>>>>> {
>>>>>    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>>>>>
>>>>>
>>>>>                    //Programatically Create and display window here
>>>>>                    //in my actuall program I have a hole bunch of
>>>>> stuff running in a while loop
>>>>>
>>>>>
>>>>> [pool release];
>>>>>
>>>>> }
>>>>>
>>>>> Any help would be great,
>>>>>                                    Dan Yocom
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Cocoa-dev mailing list      (<email_removed>)
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>>>>
>>>>> This email sent to <email_removed>
>>>>>

>>>>
>>>>

>>>

>>
>>

Related mailsAuthorDate
mlSelf terminating popup window - need help Dan Yocom Apr 14, 23:41
mlRe: Self terminating popup window - need help Joshua D. Orr Apr 15, 00:33
mlRe: Self terminating popup window - need help Dan Yocom Apr 15, 16:26
mlRe: Self terminating popup window - need help Lindsey Spratt Apr 15, 17:35
mlRe: Self terminating popup window - need help Joshua Orr Apr 15, 18:55
mlRe: Self terminating popup window - need help j o a r Apr 15, 19:50
mlRe: Self terminating popup window - need help j o a r Apr 15, 21:20