• 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: Questions about NSThread, NSRunloop, Webview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about NSThread, NSRunloop, Webview


  • Subject: Re: Questions about NSThread, NSRunloop, Webview
  • From: Stefan Heukamp <email@hidden>
  • Date: Mon, 20 Feb 2006 19:04:11 +0100

Hi,

thanks for your answer.

Have you checked the documentation:

<http://developer.apple.com/documentation/Cocoa/Conceptual/ Multithreading/articles/CocoaDetaching.html>

Search for "Configuring Your Run Loop"


that was exactly what I looked for. Now I call
[[NSRunLoop currentRunLoop] run];
and the Callback comes while the MainThread is sill busy.
But now I have a problem to end the RunLoop:

This is how i create the thread (in a small example):

- (IBAction)action:(id)sender
{
[NSThread detachNewThreadSelector:@selector(MyThreadRoutine:) toTarget:self withObject:nil];
sleep(20);
NSLog(@"awaking");
}


If this is my thread routine, there is no problem. The runloop returns immediately and the pool is released.

- (void) MyThreadRoutine:(id)anObject {
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	[[NSRunLoop currentRunLoop] run];
	[pool release];
	NSLog(@"released pool");
}

When I use this thread routine, the thread executes the runloop. When the frame is loaded I get the callback but then I want the runloop to exit.
But this just doesn't happen. Does anyone know how to end the runloop properly?
Or may it be that there is a bug?
The WebView seems to register with the RunLoop as an Input but on release it doesn't deregister. How may I do this manually?


- (void) MyThreadRoutine:(id)anObject {
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

WebView* wv = [LogWebView new];
[wv setFrameLoadDelegate:self];
[[wv mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.de";]]];


	[[NSRunLoop currentRunLoop] run];
	[pool release];
	NSLog(@"released pool");
}

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *) frame {
NSLog(@"frame loaded");
[sender setFrameLoadDelegate:nil];
[sender release];
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Questions about NSThread, NSRunloop, Webview (From: Stefan Heukamp <email@hidden>)
 >Re: Questions about NSThread, NSRunloop, Webview (From: j o a r <email@hidden>)

  • Prev by Date: Re: Looking for NSTreeController samples
  • Next by Date: Re: Find color's change in a NSString (attributed)
  • Previous by thread: Re: Questions about NSThread, NSRunloop, Webview
  • Next by thread: Re: Questions about NSThread, NSRunloop, Webview
  • Index(es):
    • Date
    • Thread