• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Runloop not being stopped by CFRunLoopStop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Runloop not being stopped by CFRunLoopStop?


  • Subject: Re: Runloop not being stopped by CFRunLoopStop?
  • From: "email@hidden" <email@hidden>
  • Date: Mon, 04 Jul 2011 17:59:28 +0100









On 4 Jul 2011, at 17:36, Matt Gough wrote:

> I have a runloop running in an NSThread. In this thread is a timer which fires every 2 seconds. In the timer, I check [NSThread isCancelled] and if so, stop the runloop via CFRunLoopStop.
>
> The runloop is run via runUntilDate:distantFuture.
>
> Shouldn't runUntilDate terminate once CFRunLoopStop has been called on it?
>
>
> I have verified that CFRunLoopStop is being called, but doGathering never finishes
>
> Any ideas?
>
1 idea.

In my case I call NSApp stop rather than accessing the runloop directly.
I find that the run loop will exit after the next event is dispatched.
If there is no next event then I don't see my runloop exit.
Therefore I generate a trigger event. Having a timer active isn't sufficient.

- (void)stopApp:(id)sender
{
#pragma unused(sender)

	// will stop run loop after next actual event object dispatched.
	// a timer doesn't count here
	[NSApp stop:self];

	// send a dummy event to trigger stopping
	NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
										location:NSMakePoint(0,0)
								   modifierFlags:0
									   timestamp:0
									windowNumber:0
										 context:nil
										 subtype:1
										   data1:1
										   data2:1];
	[NSApp postEvent:event atStart:YES];
}

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com

_______________________________________________

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

References: 
 >Runloop not being stopped by CFRunLoopStop? (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: Runloop not being stopped by CFRunLoopStop?
  • Next by Date: Re: Runloop not being stopped by CFRunLoopStop?
  • Previous by thread: Re: Runloop not being stopped by CFRunLoopStop?
  • Next by thread: Problem when load nib file
  • Index(es):
    • Date
    • Thread