Mercurial > pub > ImplabNet
annotate Implab/Parallels/ThreadPoolDispatcher.cs @ 270:ade80d94dfb5 v3
Working on Unity container xml configuration
| author | cin |
|---|---|
| date | Wed, 25 Apr 2018 04:44:40 +0300 |
| parents | 5cb4826c2c2a |
| children |
| rev | line source |
|---|---|
| 248 | 1 using System; |
| 2 using System.Threading; | |
| 3 | |
| 4 namespace Implab.Parallels { | |
| 5 public class ThreadPoolDispatcher : IDispatcher { | |
| 6 | |
| 7 public static ThreadPoolDispatcher Instance { get; private set; } = new ThreadPoolDispatcher(); | |
| 8 | |
| 9 private ThreadPoolDispatcher() { | |
| 10 } | |
| 11 | |
| 12 public void Enqueue(Action job) { | |
| 13 ThreadPool.QueueUserWorkItem((o) => job(), null); | |
| 14 } | |
| 15 | |
| 16 public void Enqueue<T>(Action<T> job, T arg) { | |
| 17 ThreadPool.QueueUserWorkItem((o) => job((T)o), arg); | |
| 18 } | |
| 19 } | |
| 20 } |
