Re: How do I use the runInNewThread method ?
Re: How do I use the runInNewThread method ?
- Subject: Re: How do I use the runInNewThread method ?
- From: kubernan <email@hidden>
- Date: Fri, 12 Oct 2001 21:19:53 +0200
Hello,
It seems runInNewThread will not "unfreeze" you app. I had this problem
in one of my app.
runInNewThread means your server can work multiple threads at once.
You have to establish a DO connection in a new thread :
- (IBAction)detachMyThread:(id)sender
{
[NSThread detachNewThreadSelector:@selector(createThread)
toTarget:self withObject:nil];
}
-(void)createThread
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init ];
NSConnection *serverConn;
id theProxy;
data_for_server = [[NSMutableDictionary alloc] init];
serverConn = [NSConnection
connectionWithRegisteredName:@"MyConnectName" host:nil];
[serverConn setRootObject:self];
theProxy = [serverConn rootProxy];
[serverConn enableMultipleThreads];
myDoConnection = [serverConn rootProxy];
if (!myDoConnection)
{
exit(EXIT_FAILURE);
}
reply = [myDoConnection myDoMethod:data_for_server];
[pool release];
[NSThread exit];
}
Hope this helps you.
Kub.
Le vendredi 12 octobre 2001, ` 10:18, Goran Granstrom a icrit :
I asked before how to run NSCOnnection in its own thread, I got the
answer to use [myConnection runInNewThread] but I don't know where I
should add that code. Should I add it when I init the NSConnection or
when I receive connections from the init-notification method. A nice
little code example would be great =)...please help, because
NSConnection freezes my app when it receive and send data so I really
need to get it to workin multithreaded mode.
/Gore
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
------------------------------------------
10191 Technologies (We build infernal machines, AI tools and more)
<
http://www.10191.com>