Mercurial > pub > ImplabNet
annotate Implab/Parallels/SyncContextDispatcher.cs @ 255:b00441e04738 v3
Adde workaround to the behaviour of the logical operations stack in conjuction
with async/await methods
| author | cin |
|---|---|
| date | Wed, 04 Apr 2018 15:38:48 +0300 |
| parents | 5cb4826c2c2a |
| children |
| rev | line source |
|---|---|
| 248 | 1 using System; |
| 2 using System.Threading; | |
| 3 | |
| 4 namespace Implab { | |
| 5 public class SyncContextDispatcher : IDispatcher { | |
| 6 SynchronizationContext m_context; | |
| 7 public SyncContextDispatcher(SynchronizationContext context) { | |
| 8 Safe.ArgumentNotNull(context, nameof(context)); | |
| 9 m_context = context; | |
| 10 } | |
| 11 | |
| 12 public void Enqueue(Action job) { | |
| 13 m_context.Post((o) => job(), null); | |
| 14 } | |
| 15 | |
| 16 public void Enqueue<T>(Action<T> job, T arg) { | |
| 17 m_context.Post((o) => job((T)o), arg); | |
| 18 } | |
| 19 } | |
| 20 } |
