Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
To the best of my knowledge no. The results would be unpredictable at best. What if the selector was altering some structure in memory and was terminated leaving the structure in an unusable state?
 
Hm... I work with iTunes through ScriptBridge, and sometimes iTunes freezes because of showing alert or something else. How i can terminate that task? Where i need to looking for?
 
Can you post the exact code you are using?

it was
Code:
	iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
it yes))
Code:
	iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
	iTunes.timeout = 5;
found it 5 secs ago
 
That timeout feature is not part of the language, it's part of Apple Events. The value you set is most likely getting sent to the AESendMessage() function as its last parameter.

Also a timeout of 5 is too small if iTunes is noticeably hanging. You should look up the # of ticks per second and calculate it off that.
 
Here's an idea I got working last week. This is to be considered pseudo code as I grabbed only portions of mine and added a little generic logic.

Note that I didn't have to worry about threading in my case, or blocking, as my object is also called via a timer. The valueImWatching gets altered via another method that gets triggered via the timer.


Code:
@interface MyObject : NSObject {
	NSDate * requestTimeOutDate;
	NSInteger timeOutLength;
        id someObject;
        id valueImWatching;
}


@implementation MyObject

-(void) timeOut: someObject {
	if ([[NSDate date] timeIntervalSinceDate: requestTimeOutDate] > timeOutLength)
	{
		NSLog(@"timed out");
		// do something, or nothing.
	else
	{
                // attempt the action I'm looking for.
		if (valueImWatching) {
		    // do something or just exit.
		} else {
		    NSLog(@"call again");
		    [NSObject cancelPreviousPerformRequestsWithTarget:self];  //selector:_cmd object: someObject];
		    [self performSelector:_cmd withObject: someObject afterDelay:1.0];
		    }
	}
}


- (void) myFirstMethod {
        valueImWatching = nil;
        someObject = [SomeObject new]; //set it up appropriately.
	requestTimeOutDate = [[NSDate date] retain]; //now
	timeOutLength = 5; // seconds of timeout
	[self timeOut: someObject];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.