private void Cancel(IInvocation invocation) { lock (_syncobject) { _isCancelled = true; var tasks = _actors.Select(a => (Task)invocation.CallOn(a.Item1 as IActorCompleteLifeCycle)).ToArray(); _actors.Clear(); invocation.ReturnValue = Task.WhenAll(tasks); } }
public void Intercept(IInvocation invocation) { if (TypeHelper.IsActorCompleteLifeCycleTypeOrBase(invocation.Method.DeclaringType)) { Cancel(invocation); return; } var actor = GetCorrectActor(); if (actor != null) { invocation.ReturnValue = invocation.CallOn(actor); } else { invocation.ReturnValue = TaskBuilder.GetCancelled(invocation.Method.ReturnType); } }