void SendUserMessage(IActor pid, object message) { var env = ResponseMessageEnvelope.Unwrap(message); if (env.Item1 is T || env.Item1 == null) { if (_cts != null && _cts.IsCancellationRequested) { return; } _tcs.TrySetResult((T)env.Item1); Pid.Stop(); } else { throw new InvalidOperationException(string.Format("Unexpected message. Was type {0} but expected {1}", env.Item1.GetType(), typeof(T))); } }
public override void Handle(ActorErrorMessage message) { _tcs.TrySetException(message.Exception); Pid.Stop(); }