How many timers?

  • Thread starter Thread starter William Stacey [MVP]
  • Start date Start date
W

William Stacey [MVP]

How many System.Threading.Timer timers can os "reasonably" handle? What is
the cost in mem? I think this is a wraper for win32 TimerQueueTimer (not
sure), but wonder what general implementation is. A queue of objects that
one thread keeps checking to see it time expired, etc. TIA
 
System.Timers.Timer is a wrapper for the NT Waitable Timer.

System.Threading.Timer is a CLR threadpool based timer which fires its events on threadpool thread. I just looked in reflector to find out the implementation details but unfortunately the crucial method AddTimerNative is marked as internalcall.

I'll have to have a dig in the ROTOR code and see.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<[email protected]>

How many System.Threading.Timer timers can os "reasonably" handle? What is
the cost in mem? I think this is a wraper for win32 TimerQueueTimer (not
sure), but wonder what general implementation is. A queue of objects that
one thread keeps checking to see it time expired, etc. TIA

--
William Stacey, MVP



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004



[microsoft.public.dotnet.languages.csharp]
 
Richard,

You are right, System.Threading.Timer takes advantage (on W2K, XP and W2K3 -
don't know about other OSses) of the OS "TimerQueue" threadpool.
By default, this thread pool has a maximum of 500 threads, as far I can see
the CLR (v1.1) doesn't change this value.
One CLR System.Threading.Timer maps onto one "timer queue timer by(calling
Win32 CreateTimerQueueTimer), so we can assume the maximum is 500.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top