internal bool Wait() { AsyncCallTracker.State state = (AsyncCallTracker.State)Interlocked.CompareExchange(ref this.state, 1, 0); if (AsyncCallTracker.State.CallerWaiting == state) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] methodName = new object[] { this.caller.MethodName, this.calleeName }; throw new InvalidOperationException(string.Format(invariantCulture, "AsyncCallTracker.Wait called twice. Caller={0}, Callee={1}", methodName)); } if (state == AsyncCallTracker.State.Begun) { return(false); } return(true); }
internal void IndicateCallComplete() { GC.SuppressFinalize(this); AsyncCallTracker.State state = (AsyncCallTracker.State)Interlocked.Exchange(ref this.state, 2); if (AsyncCallTracker.State.Complete == state) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] methodName = new object[] { this.caller.MethodName, this.calleeName, this.activityId }; throw new InvalidOperationException(string.Format(invariantCulture, "AsyncCallTracker.IndicateCallComplete called twice. Caller={0}, Callee={1}, this.activityId={2}", methodName)); } if (AsyncCallTracker.State.CallerWaiting == state) { AsyncHelper.Trace.ActivityId = this.activityId; AsyncHelper.Trace.Metadata = this.metadata; this.caller.ResumeExecution(); } }