From: Charles on
I asked a question related to this a little while ago, and thought that I'd
got my answer, but it has come back to bite me again.

I currently use a System.Threading.Timer to generate a tick every 10
seconds. At each tick, I execute some code that will take a maximum of 5
seconds to complete. Most of the time, each subsequent tick occurs at
exactly 10 seconds after the previous one, but occasionally there can be as
much as 20 or 30 seconds between ticks.

It was explained, in the previous thread, that the Threading timer relies on
WM_TIMER messages, which are low down on the priority list. If the system
gets a bit busy then these message seem to come further apart, so my tick
interval extends.

What I need is a reliable way to generate a 10 second tick, that still works
when the system gets a bit busy. I'm running this on Windows Server 2003 R2
x64, if that makes any difference.

Does anyone have any ideas?

TIA

Charles


From: Family Tree Mike on
On 5/20/2010 9:51 AM, Charles wrote:
> I asked a question related to this a little while ago, and thought that
> I'd got my answer, but it has come back to bite me again.
>
> I currently use a System.Threading.Timer to generate a tick every 10
> seconds. At each tick, I execute some code that will take a maximum of 5
> seconds to complete. Most of the time, each subsequent tick occurs at
> exactly 10 seconds after the previous one, but occasionally there can be
> as much as 20 or 30 seconds between ticks.
>
> It was explained, in the previous thread, that the Threading timer
> relies on WM_TIMER messages, which are low down on the priority list. If
> the system gets a bit busy then these message seem to come further
> apart, so my tick interval extends.
>
> What I need is a reliable way to generate a 10 second tick, that still
> works when the system gets a bit busy. I'm running this on Windows
> Server 2003 R2 x64, if that makes any difference.
>
> Does anyone have any ideas?
>
> TIA
>
> Charles
>
>

To get exactly 10 seconds between ticks, you need a real-time operating
system. Windows is not a real-time OS. You will need to rethink the
requirement, or rethink the computing platform.

--
Mike
From: Davej on
On May 20, 8:51 am, "Charles" <bl...(a)nowhere.com> wrote:
> [...] Most of the time, each subsequent tick occurs at
> exactly 10 seconds after the previous one, but occasionally
> there can be as much as 20 or 30 seconds between ticks.
>

You've looked here?

http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx

From: Charles on
Hi Mike

Thanks for the reply. To be honest, I'd be happy with 10 seconds +/- 5
seconds, which doesn't seem to much to ask. Or is it?

Charles


"Family Tree Mike" <FamilyTreeMike(a)ThisOldHouse.com> wrote in message
news:#NQkzUD#KHA.5464(a)TK2MSFTNGP05.phx.gbl...
> On 5/20/2010 9:51 AM, Charles wrote:
>> I asked a question related to this a little while ago, and thought that
>> I'd got my answer, but it has come back to bite me again.
>>
>> I currently use a System.Threading.Timer to generate a tick every 10
>> seconds. At each tick, I execute some code that will take a maximum of 5
>> seconds to complete. Most of the time, each subsequent tick occurs at
>> exactly 10 seconds after the previous one, but occasionally there can be
>> as much as 20 or 30 seconds between ticks.
>>
>> It was explained, in the previous thread, that the Threading timer
>> relies on WM_TIMER messages, which are low down on the priority list. If
>> the system gets a bit busy then these message seem to come further
>> apart, so my tick interval extends.
>>
>> What I need is a reliable way to generate a 10 second tick, that still
>> works when the system gets a bit busy. I'm running this on Windows
>> Server 2003 R2 x64, if that makes any difference.
>>
>> Does anyone have any ideas?
>>
>> TIA
>>
>> Charles
>>
>>
>
> To get exactly 10 seconds between ticks, you need a real-time operating
> system. Windows is not a real-time OS. You will need to rethink the
> requirement, or rethink the computing platform.
>
> --
> Mike

From: Charles on
Hi Dave

Yes, I have. It was my understanding that the Timers timer was just a
wrapper for the Threading timer. Perhaps not. There doesn't seem to be
anything there that suggests it is any more reliable the the threading
version. If it doesn't use WM_TIMER messages, do you know how it does work?

Thanks

Charles


"Davej" <galt_57(a)hotmail.com> wrote in message
news:a38d2fce-5230-42bd-833c-e9b6748bf691(a)h37g2000pra.googlegroups.com...
> On May 20, 8:51 am, "Charles" <bl...(a)nowhere.com> wrote:
>> [...] Most of the time, each subsequent tick occurs at
>> exactly 10 seconds after the previous one, but occasionally
>> there can be as much as 20 or 30 seconds between ticks.
>>
>
> You've looked here?
>
> http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx
>