View Full Version : control a detached Thread...

Nov 13, 2008, 11:38 PM
Hi all,

Is it possible to control a detached thread??
Say. i am showing a alertView (text="Loading..", Button =Cancel) on detaching a thread which perform some server communication...
I want to giv User the flexiblity to cancel the detached thread (ConnectionHandler method) on clicking the "Cancel" button of alertView.

I know NSThread is having "cancel" method, But how to "Cancel" a detached thread?

Getting user inputs
Show alertView (text="Loading..", Button =Cancel)
[Detach a thread with action:@selector(connectToServer:)

// Do server communication and get response..
[self performSelectorOnMainThread with action:@selector(doneConn:)
dismiss current showing alertView


Adding to above info:

I tried creating a thread object and initWith same selctor..
Problem is that.. in connectToServer method, i am calling another method which will really create connection using sendSynchronousRequest method of NSURLConnection.
My thread is getting cancelled only after executing sendSynchronousRequest, means... i cant cancel the Connection (in mid way of executing the same...)

Thanks for any help