예제 #1
0
        /// <summary>
        /// Release any resources associated with this object.
        /// </summary>
        public void Dispose()
        {
            using (TimedLock.Lock(this))
            {
#if DEBUG && !MOBILE_DEVICE
                if (!isCompleted)
                {
                    AsyncTracker.Dump(this, "Disposing AsyncResult before operation completes.");
                    SysLog.LogErrorStackDump("Disposing AsyncResult before operation completes.");
                    return;
                }

                if (disposed)
                {
                    var sb = new StringBuilder(1024);

                    AsyncTracker.Dump(this, "AsyncResult has already been disposed.");

                    sb.AppendLine("AsyncResult has already been disposed.");
                    sb.AppendLine();
                    sb.AppendLine("Current stack:");
                    CallStack.AsyncTrace(1, true).Dump(sb);
                    sb.AppendLine();
                    sb.AppendLine("Completion stack:");
                    completeStack.Dump(sb);

                    SysLog.LogError(sb.ToString());
                    return;
                }

                this.disposed      = true;
                this.completeStack = CallStack.AsyncTrace(1, true);
#endif
                if (wait != null)
                {
                    wait.Close();
                    wait = null;
                }
            }

#if !MOBILE_DEVICE
            AsyncTracker.Yield();
#endif
        }