annotate Implab/Parallels/SyncContextDispatcher.cs @ 249:d82909310094 v3

Implab.Test moved to xunit Complete set of PromiseHelpers (Then, Catch, Finally) Removed obsolete types ICancellable, ICancellationToken
author cin
date Wed, 31 Jan 2018 11:28:38 +0300
parents 5cb4826c2c2a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
1 using System;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
2 using System.Threading;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
3
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
4 namespace Implab {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
5 public class SyncContextDispatcher : IDispatcher {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
6 SynchronizationContext m_context;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
7 public SyncContextDispatcher(SynchronizationContext context) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
8 Safe.ArgumentNotNull(context, nameof(context));
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
9 m_context = context;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
10 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
11
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
12 public void Enqueue(Action job) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
13 m_context.Post((o) => job(), null);
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
14 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
15
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
16 public void Enqueue<T>(Action<T> job, T arg) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
17 m_context.Post((o) => job((T)o), arg);
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
18 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
19 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
20 }