RE: Asynchronous Methods Question
RE: Asynchronous Methods Question
- Subject: RE: Asynchronous Methods Question
- From: "Josh Ferguson" <email@hidden>
- Date: Fri, 18 Nov 2005 11:09:36 -0600
- Thread-topic: Asynchronous Methods Question
Thanks for the input. I should clarify what I mean by 'blocking'. Lets
say that my framework has an entry point 'MyFunction()' that returns a
success or a failure.
MyFunction() calls -[NSURLConnection initWithRequest:delegate:] which
handles some communication with the server. If I just call this directly
from MyFunction, then control will return from MyFunction and a result
will be returned before the download is complete. I don't want to return
from MyFunction() until the download is finished (and I need progress
information, so I can't do a synchronous request). I don't want to block
all events, I just want to prevent control from returning from the
function. Hence my idea of using the NSRunLoop commands to accept events
while it's sitting in the function. Does this make sense?
Josh Ferguson
-----Original Message-----
From: AgentM [mailto:email@hidden]
Sent: Friday, November 18, 2005 10:59 AM
To: Josh Ferguson
Subject: Re: Asynchronous Methods Question
In general, it is best not to block the runloop because that causes
the beach ball of death. It is possible to call the runloop from
inside your routine, but that can make it harder to debug. Instead,
you should have a method that is the callback method for the
downloads completing. Once all downloads are done, you can message
the requisite controller class that all downloads are complete.
If you are performing the download in a sheet, keep in mind that the
runloop is not the main runloop. Good luck.
On Nov 18, 2005, at 10:31 AM, Josh Ferguson wrote:
> So this is probably a newbie question, but I thought I'd ask it
> anyway.
> I'm writing a framework that requires initiating several
> connections to
> a server. I'm using NSURLConnection to create asynchronous connections
> so I can update a progress bar. My problem is that I need to block the
> entry point until the asynchronous connections are finished
> downloading.
> So, in other words, when a call is made to the framework, I need to
> initiate all these connections and wait for them to finish before
> returning from the function/method. What's the recommended method for
> blocking a function/method from returning? Should I sit in a while
> loop
> with one of the -[NSRunLoop run] methods? Or is there a better way?
>
>
>
> Thanks!
>
>
>
> Josh
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40themactionfaction.com
>
> This email sent to email@hidden
>
|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-
AgentM
email@hidden
|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-
_______________________________________________
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