DO & Thread problems
DO & Thread problems
- Subject: DO & Thread problems
- From: kubernan <email@hidden>
- Date: Sat, 11 Aug 2001 16:01:45 +0200
Hello,
In my app, i use a new thread when i want to sent message to other
process via DO.
At the end of the thread my goal is to release some objects.
It appears :
- i don't receive any NSThreadWillExitNotification
- If i create my NSConnection in the thread, all code after the
remote process call
is executed. If i create my NSConnection in the -awakeFromNib
all code after the remote call *seems* to be not executed.
Here's my code :
- (void)awakeFromNib
{
id theProxy;
int return_code;
serverConn = [[NSConnection
connectionWithRegisteredName:@"ThreadedNeuralNetwork" host:nil] retain];
[serverConn setRootObject:self];
theProxy = [[serverConn rootProxy] retain];
[serverConn enableMultipleThreads];
threadedNeuralNetwork = [[serverConn rootProxy] retain];
if (!threadedNeuralNetwork)
{
return_code = NSRunAlertPanel(@"Interactive braininabox", @"An
element is missing. Please reinstall interactive braininabox.",
@"Ok",nil,nil);
exit(EXIT_FAILURE);
}
}
- (IBAction)callRemoteProcess:(id)sender
{
// some code
[[NSNotificationCenter defaultCenter] addObserver:self // DON'T
WORK
selector:@selector(threadExit:)
name:NSThreadWillExitNotification
object:nil];
/* ----- test thread --------- */
[NSThread detachNewThreadSelector:@selector(ThreadTest:)
toTarget:self withObject:data_for_server];
/* ----- fin test thread --------- */
[informationField setStringValue:@"Processing your request"];
}
-(void)ThreadTest:(bycopy NSMutableDictionary*)data_for_server2
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init ];
[threadedNeuralNetwork network_process:data_for_server2]; // call
the server....IT WORK'S
[pool release];
[NSThread exit];
NSLog(@"Hey ?");
}
-(void)threadExit:(NSNotification*)theNotification // NEVER
CALLED ... WHY ????
{
NSLog(@"Hey");
NSBeep();
// WANT TO RELEASE SOME OBJECTS HERE !
[informationField setStringValue:@"Process ended"];
}
Kub. Thx for you help !