• 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: How can I stop running loop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I stop running loop?


  • Subject: Re: How can I stop running loop?
  • From: John Stiles <email@hidden>
  • Date: Tue, 23 Nov 2004 13:52:59 -0800

If possible, make your code use an NSTimer:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSTimer.html


NSTimer lets you call a function periodically. You can check for data inside the NSTimer callback. This way you avoid threading hassles and don't consume the user's CPU unnecessarily. Make sure your timer has a reasonable polling frequency--i.e. checking 10 or 20 times a second should be more than enough if all you're doing is polling for data.


On Nov 23, 2004, at 1:48 PM, Mai Bui wrote:

Hi,

I'm very new in cocoa and still learning it. I would like to write application which is run forever (to acquire some data) until the user enter some key (i.e "Q") and application will stop.
I think about use multithread to do it: the first thread runs a while(1) loop, the second one waits, checks and gets input from the user to set the flag "Done" which is the first thread can see it and stop. My logic is on the right track? But .... I do not know how to implement with the second thread.


Thanks for your ideas, your guide in advance.

Mai.


Mai Bui N. MPL - SIO email@hidden (858)534-4733

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >How can I stop running loop? (From: Mai Bui <email@hidden>)

  • Prev by Date: Re: Using mouseEntered and mouseExited
  • Next by Date: Re: Button doesn't respond in a modal sheet created from window NIB
  • Previous by thread: How can I stop running loop?
  • Next by thread: Re: How can I stop running loop?
  • Index(es):
    • Date
    • Thread