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