[SOLVED] Re: DO & Thread problems
[SOLVED] Re: DO & Thread problems
- Subject: [SOLVED] Re: DO & Thread problems
- From: kubernan <email@hidden>
- Date: Sun, 12 Aug 2001 00:48:52 +0200
Yessss....
My DO requests are multithreaded. My app. allows to launch multiple times
the same window and, in each window i can establish a DO request to a
server at once.
The pb i had was during the reply of the server : server and client app
crashed each time
at the first reply of one of this window.
I thought it was a client problem due to a failed memory management
(that's why i had the idea to catch NSThreadWillExitNotification
for deallocating the appropriate objects).
In fact the problem was in server side : it deallocated all instances
for all request even
if some of them still running.
I fixed the server (very hard to fix because it's C++/ObjC code). All is
working now.
Now i can sleep.
Happy coding all !
Le samedi 11 ao{t 2001, ` 04:01, kubernan a icrit :
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 !
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev