confusing events
confusing events
- Subject: confusing events
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 10 Sep 2007 14:59:13 +0200
I have a class
@interface MyClass : NSObject <My_Protocol>
@end
@implementation MyClass
-(void)main;
{
NSLog(@"%s start",__FUNCTION__);
// do something mainly
NSLog(@"%s end",__FUNCTION__);
}
-(oneway void)process
{
NSLog(@"%s",__FUNCTION__);
// do some processing
}
@end
MyClass lives in the main thread and gets process-messages via
Distributed Objects (NSConnection) from a worker thread.
Sometimes I see:
-[MyClass main] start
-[MyClass process]
-[MyClass main] end
That is:
- some event starts the main method (actually it is [myClass
performSelector: @selector(main) withObject: nil afterDelay: 0.0 ]),
- then the execution is interrupted and switched to the process method,
- then main resumes and runs until its end.
All run in the same thread (I did log [NSThread currentThread]).
I think this, i.e. the fact that the method triggered by an event
does NOT run to its end, but gets interruped by another method (in
the same thread), extremely confusing.
Could someone point to some helpful documentation ?
Kind regards,
Gerriet.
P.S. My current work-around is:
-(oneway void)process
{
[self performSelector: @selector(realProcess) withObject: nil
afterDelay: 0.0 ];
}
-(void)realProcess
{
NSLog(@"%s",__FUNCTION__);
// do some processing
}
Now realProcess and main are no longer interleaved and all is fine.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden