Re: NSTimer not firing when computer is inactive for a while.

2017-11-14 Thread Jens Alfke


> On Nov 14, 2017, at 4:43 PM, Nathan Day  wrote:
> 
> The background app is kept alive by launchd as a User Agent and looks for new 
> resources to be downloaded periodically

If this is a launchd agent, you can configure its plist so it gets launched 
periodically. That way it won’t have to keep running all the time; it can just 
poll the network, then quit if there’s nothing to download.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer not firing when computer is inactive for a while.

2017-11-14 Thread Quincey Morris
On Nov 14, 2017, at 16:57 , Quincey Morris 
 wrote:
> 
> I would suggest you try setting the QoS to at least “utility”, perhaps even 
> “user initiated”.

To clarify: *what* you set to a different QoS depends on the nature of the 
thing you described as a “background process”. For example, if you’re using 
XPC, I think you can change the QoS of the XPC service as a whole. Changing the 
QoS of a particular thread may not be the correct solution.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer not firing when computer is inactive for a while.

2017-11-14 Thread Quincey Morris
On Nov 14, 2017, at 16:43 , Nathan Day  wrote:
> 
> I have a background process that uses an NSTimer that is set to fire every 
> minute, but when the computer is inactive for a while it will stop firing

My guess is that it’s not a problem with the timer, but with the quality of 
service (QoS) of the thread that’s servicing the timer. If this is a background 
process, it may be that the default QoS is “background”, which allows the 
system to defer execution indefinitely. I would suggest you try setting the QoS 
to at least “utility”, perhaps even “user initiated”.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer not firing when computer is inactive for a while.

2017-11-14 Thread Nathan Day

I should make it clear, this is a Mac OS X application.

Nathan Day

On 14 Nov, 2017, at 01:43 PM, Nathan Day  wrote:

I have a background process that uses an NSTimer that is set to fire every 
minute, but when the computer is inactive for a while it will stop firing, its 
not until someone interacts with the computer the timer will start firing 
again. The timer is added to the main NSRunLoop, maybe the NSRunLoop needs to 
be kept active by user interaction, the background app has a status menu bar 
item to provide feedback when its active and provide a simple menu for basic 
user control.

I have checked "Prevent computer from sleeping automatically when the display is off" in 
Energy Saver, I have also tried setting "Turn display off after" to never but it doesn't 
make a difference, these are things we can control on the users machines because it runs on company 
computers.

The background app is kept alive by launchd as a User Agent and looks for new 
resources to be downloaded periodically, it needs to start downloading these 
resources not to long after they are available, they can take hours to download 
in some case, and they need to be available when the user returns to their 
computer. There is also a foreground app that talks to the background app to 
display the downloaded resources, a bit like iTunes and iTunes Helper.

Nathan Day
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/nathan_day%40mac.com

This email sent to nathan_...@mac.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTimer not firing when computer is inactive for a while.

2017-11-14 Thread Nathan Day

I have a background process that uses an NSTimer that is set to fire every 
minute, but when the computer is inactive for a while it will stop firing, its 
not until someone interacts with the computer the timer will start firing 
again. The timer is added to the main NSRunLoop, maybe the NSRunLoop needs to 
be kept active by user interaction, the background app has a status menu bar 
item to provide feedback when its active and provide a simple menu for basic 
user control.

I have checked "Prevent computer from sleeping automatically when the display is off" in 
Energy Saver, I have also tried setting "Turn display off after" to never but it doesn't 
make a difference, these are things we can control on the users machines because it runs on company 
computers.

The background app is kept alive by launchd as a User Agent and looks for new 
resources to be downloaded periodically, it needs to start downloading these 
resources not to long after they are available, they can take hours to download 
in some case, and they need to be available when the user returns to their 
computer. There is also a foreground app that talks to the background app to 
display the downloaded resources, a bit like iTunes and iTunes Helper.

Nathan Day
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com