annotate Implab/SyncContextPromise.cs @ 72:d67b95eddaf4 v2

promises refactoring
author cin
date Thu, 04 Sep 2014 18:47:12 +0400
parents
children 279e226dffdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
1 using System.Threading;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
2
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
3 namespace Implab {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
4 public class SyncContextPromise<T> : Promise<T> {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
5 readonly SynchronizationContext m_context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
6
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
7 public SyncContextPromise(SynchronizationContext context) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
8 Safe.ArgumentNotNull(context, "context");
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
9 m_context = context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
10 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
11
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
12 public SyncContextPromise(SynchronizationContext context, IPromise parent, bool cancellable)
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
13 : base(parent, cancellable) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
14 Safe.ArgumentNotNull(context, "context");
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
15 m_context = context;
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
16 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
17 protected override void InvokeHandler(HandlerDescriptor handler) {
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
18 m_context.Post(x => base.InvokeHandler(handler),null);
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
19 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
20 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
21 }
d67b95eddaf4 promises refactoring
cin
parents:
diff changeset
22