• 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: Avoiding UI hangs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding UI hangs


  • Subject: Re: Avoiding UI hangs
  • From: Anthony Duer <email@hidden>
  • Date: Sun, 4 Sep 2005 03:08:33 -0700

Hey Sanri,

You've actually got most of it down. However, NSAutoreleasePool isn't what you need to create a new thread to avoid hanging your UI during upload. To spawn a thread, use this:

....
[urlHandle setPutFile:fileToUpload];
[NSThread detachNewThreadSelector: @selector(startUpload:) toTarget: self withObject: urlHandle];


Your startUpload method will then have to be adjusted slightly:

-(void)startUpload:(CURLHandle *)handle
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[handle prepareAndPerformCurl];
if (![[handle curlError] isEqualToString:@""])
{
[self performSelectorOnMainThread: @selector(failed:) withObject: [handle curlError] waitUntilDone: NO];
//This should be performed on the main thread since it involves the UI.
//NSBeginAlertSheet(@"Upload
error",@"Ok",nil,nil,g_finPrincipale,self,nil,nil,nil,[NSString
stringWithFormat:@"Upload failed\nHere's the error generated by
CURL:\n\n %@",[handle curlError]]);
}
[pool release];
[NSThread exit];
}


That should be it to getting your thread going. Good luck. :)

~Anthony Duer
_______________________________________________
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


  • Prev by Date: Re: Core Data : where are the docs ?
  • Next by Date: Re: 3rd Party Components
  • Previous by thread: Re: Avoiding UI hangs
  • Next by thread: Fwd: ANN: netclasses 1.05
  • Index(es):
    • Date
    • Thread