SyncContextPromise.cs
26 lines
| 886 B
| text/x-csharp
|
CSharpLexer
/ Implab / SyncContextPromise.cs
|
|
r72 | using System.Threading; | ||
|
|
r138 | using System; | ||
|
|
r72 | |||
| namespace Implab { | ||||
| public class SyncContextPromise<T> : Promise<T> { | ||||
| readonly SynchronizationContext m_context; | ||||
| public SyncContextPromise(SynchronizationContext context) { | ||||
| Safe.ArgumentNotNull(context, "context"); | ||||
| m_context = context; | ||||
| } | ||||
|
|
r145 | protected override void SignalSuccess(Promise<T>.HandlerDescriptor handler) { | ||
|
|
r119 | m_context.Post(x => base.SignalSuccess(handler), null); | ||
|
|
r72 | } | ||
|
|
r119 | |||
|
|
r145 | protected override void SignalError(Promise<T>.HandlerDescriptor handler, Exception error) { | ||
|
|
r119 | m_context.Post(x => base.SignalError(handler, error), null); | ||
| } | ||||
|
|
r145 | protected override void SignalCancelled(Promise<T>.HandlerDescriptor handler, Exception reason) { | ||
|
|
r138 | m_context.Post(x => base.SignalCancelled(handler, reason), null); | ||
|
|
r72 | } | ||
| } | ||||
| } | ||||
