using System;
using System.Threading;
namespace System.ComponentModel
{
/// Tracks the lifetime of an asynchronous operation.
// Token: 0x02000055 RID: 85
public sealed class AsyncOperation
{
// Token: 0x06000348 RID: 840 RVA: 0x0000A2F0 File Offset: 0x000084F0
internal AsyncOperation(SynchronizationContext ctx, object state)
{
this.ctx = ctx;
this.state = state;
ctx.OperationStarted();
}
// Token: 0x06000349 RID: 841 RVA: 0x0000A30C File Offset: 0x0000850C
~AsyncOperation()
{
if (!this.done && this.ctx != null)
{
this.ctx.OperationCompleted();
}
}
/// Gets the object that was passed to the constructor.
/// The object that was passed to the constructor.
// Token: 0x170000E6 RID: 230
// (get) Token: 0x0600034A RID: 842 RVA: 0x0000A364 File Offset: 0x00008564
public SynchronizationContext SynchronizationContext
{
get
{
return this.ctx;
}
}
/// Gets or sets an object used to uniquely identify an asynchronous operation.
/// The state object passed to the asynchronous method invocation.
// Token: 0x170000E7 RID: 231
// (get) Token: 0x0600034B RID: 843 RVA: 0x0000A36C File Offset: 0x0000856C
public object UserSuppliedState
{
get
{
return this.state;
}
}
/// Ends the lifetime of an asynchronous operation.
///
/// has been called previously for this task.
///
///
///
// Token: 0x0600034C RID: 844 RVA: 0x0000A374 File Offset: 0x00008574
public void OperationCompleted()
{
if (this.done)
{
throw new InvalidOperationException("This task is already completed. Multiple call to OperationCompleted is not allowed.");
}
this.ctx.OperationCompleted();
this.done = true;
}
/// Invokes a delegate on the thread or context appropriate for the application model.
/// A object that wraps the delegate to be called when the operation ends.
/// An argument for the delegate contained in the parameter.
/// The method has been called previously for this task.
///
/// is null.
// Token: 0x0600034D RID: 845 RVA: 0x0000A3AC File Offset: 0x000085AC
public void Post(SendOrPostCallback d, object arg)
{
if (this.done)
{
throw new InvalidOperationException("This task is already completed. Multiple call to Post is not allowed.");
}
this.ctx.Post(d, arg);
}
/// Ends the lifetime of an asynchronous operation.
/// A object that wraps the delegate to be called when the operation ends.
/// An argument for the delegate contained in the parameter.
///
/// has been called previously for this task.
///
/// is null.
// Token: 0x0600034E RID: 846 RVA: 0x0000A3D4 File Offset: 0x000085D4
public void PostOperationCompleted(SendOrPostCallback d, object arg)
{
if (this.done)
{
throw new InvalidOperationException("This task is already completed. Multiple call to PostOperationCompleted is not allowed.");
}
this.Post(d, arg);
this.OperationCompleted();
}
// Token: 0x04000115 RID: 277
private SynchronizationContext ctx;
// Token: 0x04000116 RID: 278
private object state;
// Token: 0x04000117 RID: 279
private bool done;
}
}