Use System.Threading.Timer with CustomThreadPool?

So, according to MSDN , System.Threading.Timer calls it the callback delegate on the ThreadPool thread. Is there a way to do this with a custom ThreadPool? (For example, Jon Skeet CustomThreadPool.)

+2


source to share


1 answer


Do not use System.Threading.Timer

, no. Usage System.Timers.Timer

I suppose you could if the appropriate thread pool implemented ISynchronizeInvoke

accordingly. I believe the timer will call BeginInvoke

on its own SynchronizingObject

to execute the callback accordingly. If the thread pool has implemented ISynchronizeInvoke

to mean "add callback to work queue", it should work fine.



(Mine doesn't implement it, but it probably won't be too hard to do. My thread pool is very primitive, or at least very old! - there are almost certainly better ones available now.)

+5


source







All Articles