Wayne Bloss
Wayne Bloss

Reputation: 5550

Use System.Threading.Timer with CustomThreadPool?

So, according to MSDN, System.Threading.Timer calls it's callback delegate on a ThreadPool thread. Is there any way to make it use a custom ThreadPool? (For instance, Jon Skeet's CustomThreadPool.)

Upvotes: 2

Views: 201

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502016

Not using System.Threading.Timer, no. Using System.Timers.Timer I believe you could if the thread pool in question implemented ISynchronizeInvoke accordingly. I believe the timer will call BeginInvoke on its SynchronizingObject to execute the callback accordingly. If a thread pool implemented ISynchronizeInvoke to mean "add the callback to the work queue" it should work fine.

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

Upvotes: 5

Related Questions