public override void Post(SendOrPostCallback d, object state)
{
if (s_synchronousPostEnabled)
{
s_synchronousPostEnabled = false;
if (s_currentAtomicContext == null)
{
using (new SynchronizationContextSwitcher(new ActorSynchronizationContext(_context)))
{
d(state);
}
return;
}
if (s_currentAtomicContext == _context)
{
s_currentAtomicContext = null;
using (new SynchronizationContextSwitcher(new ActorSynchronizationContext(_context)))
{
d(state);
}
return;
}
else
{
s_currentAtomicContext = null;
}
}
if (_context.CancellationToken.IsCancellationRequested)
return;
_context.Self.Tell(
new TaskContinuationMessage
{
Context = _context,
CallbackAction = d,
CallbackState = state
},
_context.Sender);
}