// Decompiled with JetBrains decompiler // Type: Rei.Net.HttpServer.MyAsyncResult // Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null // MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28 // Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll using Microsoft.VisualBasic.CompilerServices; using System; using System.Runtime.CompilerServices; using System.Threading; namespace Rei.Net.HttpServer { public class MyAsyncResult : IAsyncResult { private AsyncCallback _callback; private object _asyncstate; private bool _iscompleted; private bool _isended; private bool _async; private ManualResetEvent _waithandle; private object _returnvalue; private object _syncobject; private IAsyncResult _baseasyncresult; private object _tag; private Exception _ex; public MyAsyncResult(AsyncCallback callback, object asyncstate) { this._callback = callback; this._asyncstate = RuntimeHelpers.GetObjectValue(asyncstate); this._isended = false; this._iscompleted = false; this._async = false; this._waithandle = (ManualResetEvent) null; this._returnvalue = (object) null; this._syncobject = RuntimeHelpers.GetObjectValue(new object()); } public bool IsCompleted { get { return this._iscompleted; } } public object AsyncState { get { return this._asyncstate; } } public bool CompletedSynchronously { get { return this.IsCompleted && !this._async; } } public WaitHandle AsyncWaitHandle { get { object syncobject = this._syncobject; ObjectFlowControl.CheckForSyncLockOnValueType(syncobject); Monitor.Enter(syncobject); try { if (this._waithandle == null) this._waithandle = new ManualResetEvent(this._iscompleted); } finally { Monitor.Exit(syncobject); } return (WaitHandle) this._waithandle; } } internal object ReturnValue { get { return this._returnvalue; } set { this._returnvalue = RuntimeHelpers.GetObjectValue(value); } } internal IAsyncResult BaseAsyncResult { get { return this._baseasyncresult; } set { this._baseasyncresult = value; } } internal object Tag { get { return this._tag; } set { this._tag = RuntimeHelpers.GetObjectValue(value); } } internal void SetAsync() { this._async = true; } internal void Complete(Exception ex) { object syncobject = this._syncobject; ObjectFlowControl.CheckForSyncLockOnValueType(syncobject); Monitor.Enter(syncobject); try { if (this._iscompleted) throw new InvalidOperationException(); this._iscompleted = true; this._ex = ex; if (this._waithandle != null) this._waithandle.Set(); } finally { Monitor.Exit(syncobject); } Exception ex1 = this._ex; if (this._callback == null) return; this._callback((IAsyncResult) this); } internal void Complete() { this.Complete((Exception) null); } internal void AsyncEnd() { object syncobject1 = this._syncobject; ObjectFlowControl.CheckForSyncLockOnValueType(syncobject1); Monitor.Enter(syncobject1); bool iscompleted; try { if (this._isended) throw new InvalidOperationException(); this._isended = true; iscompleted = this._iscompleted; } finally { Monitor.Exit(syncobject1); } if (!iscompleted) this.AsyncWaitHandle.WaitOne(); object syncobject2 = this._syncobject; ObjectFlowControl.CheckForSyncLockOnValueType(syncobject2); Monitor.Enter(syncobject2); try { if (this._waithandle != null) this._waithandle.Close(); } finally { Monitor.Exit(syncobject2); } if (this._ex != null) throw new Exception("error", this._ex); } } }