199 lines
4.4 KiB
C#
199 lines
4.4 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Rei.Fs.MyAsyncResult
|
|
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
|
|
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
|
|
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
|
|
|
|
using Microsoft.VisualBasic.CompilerServices;
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading;
|
|
|
|
namespace Rei.Fs
|
|
{
|
|
public class MyAsyncResult : IAsyncResult
|
|
{
|
|
private AsyncCallback _callback;
|
|
private object _asyncstate;
|
|
private bool _iscompleted;
|
|
private bool _isended;
|
|
private bool _completesync;
|
|
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._iscompleted = false;
|
|
this._isended = false;
|
|
this._completesync = true;
|
|
this._waithandle = (ManualResetEvent) null;
|
|
this._returnvalue = (object) null;
|
|
this._syncobject = RuntimeHelpers.GetObjectValue(new object());
|
|
}
|
|
|
|
public bool IsCompleted
|
|
{
|
|
get
|
|
{
|
|
object syncobject = this._syncobject;
|
|
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
|
|
Monitor.Enter(syncobject);
|
|
try
|
|
{
|
|
return this._iscompleted;
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(syncobject);
|
|
}
|
|
}
|
|
}
|
|
|
|
public object AsyncState
|
|
{
|
|
get
|
|
{
|
|
return this._asyncstate;
|
|
}
|
|
}
|
|
|
|
public bool CompletedSynchronously
|
|
{
|
|
get
|
|
{
|
|
return this._completesync;
|
|
}
|
|
}
|
|
|
|
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 SetCompleteAsync()
|
|
{
|
|
this._completesync = false;
|
|
}
|
|
|
|
internal void AsyncComplete()
|
|
{
|
|
this.AsyncComplete((Exception) null);
|
|
}
|
|
|
|
internal void AsyncComplete(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);
|
|
}
|
|
if (this._callback == null)
|
|
return;
|
|
this._callback((IAsyncResult) this);
|
|
}
|
|
|
|
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 this._ex;
|
|
}
|
|
}
|
|
}
|