Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: NSURLConnection Getting delegate responses off main thread.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection Getting delegate responses off main thread.



On Tuesday, July 29, 2003, at 02:00 PM, Derek Shaw wrote:

I wonder if I am just too early an adopter for some of this stuff :-)

Probably; join the club :-)

I have a separate thread from my main application that I need to get an
NSURLConnection running in. We had some custtom HTTP code that I want to
replace with the wonderful NSURL framework :-)

IME WebKit isn't very happy running multi-threaded; trying to load two WebViews in separate threads resulted in bad behavior, though I didn't try to investigate more fully. Plain Web Foundation might work better though.


Keep in mind, I inherited the thread code so I am not all that familiar with
it.


My thread is started like this:
[...]
So does the initWithRequest add a port of some kind onto the threads run
loop? What order should I do things in, if any?


I have tried calling [currentRunLoop run] on the thread before creating the
connection as well as polling using


[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate
distantFuture]]


No matter what I seem to do, the delegate methods never get called after
calling initWithRequest. Which does return successfully.

Run loops don't run automagically except in the main thread (where NSApplication runs it, I think). You have to keep calling a method which runs the run loop (I like limitDateForMode:) in your workerThreadProc (after doing the initWithRequest) or nothing will run. I think runMode:beforeDate distantFuture might not work because it runs the run loop only once, then blocks.


Another option is to restructure workerThreadProc so the queue is an input to the run loop, and make workerThreadProc itself do nothing but run the run loop. I don't know the details of how to do that.
_______________________________________________
webkitsdk-dev mailing list | email@hidden
Help/Unsubscribe: http://www.lists.apple.com/mailman/listinfo/webkitsdk-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSURLConnection Getting delegate responses off main thread. (From: Derek Shaw <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.