112 lines
4.5 KiB
C#
112 lines
4.5 KiB
C#
using System;
|
|
using System.Threading;
|
|
|
|
namespace System.ComponentModel
|
|
{
|
|
/// <summary>Tracks the lifetime of an asynchronous operation.</summary>
|
|
// 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();
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the <see cref="T:System.Threading.SynchronizationContext" /> object that was passed to the constructor.</summary>
|
|
/// <returns>The <see cref="T:System.Threading.SynchronizationContext" /> object that was passed to the constructor.</returns>
|
|
// Token: 0x170000E6 RID: 230
|
|
// (get) Token: 0x0600034A RID: 842 RVA: 0x0000A364 File Offset: 0x00008564
|
|
public SynchronizationContext SynchronizationContext
|
|
{
|
|
get
|
|
{
|
|
return this.ctx;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets or sets an object used to uniquely identify an asynchronous operation.</summary>
|
|
/// <returns>The state object passed to the asynchronous method invocation.</returns>
|
|
// Token: 0x170000E7 RID: 231
|
|
// (get) Token: 0x0600034B RID: 843 RVA: 0x0000A36C File Offset: 0x0000856C
|
|
public object UserSuppliedState
|
|
{
|
|
get
|
|
{
|
|
return this.state;
|
|
}
|
|
}
|
|
|
|
/// <summary>Ends the lifetime of an asynchronous operation.</summary>
|
|
/// <exception cref="T:System.InvalidOperationException">
|
|
/// <see cref="M:System.ComponentModel.AsyncOperation.OperationCompleted" /> has been called previously for this task. </exception>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// 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;
|
|
}
|
|
|
|
/// <summary>Invokes a delegate on the thread or context appropriate for the application model.</summary>
|
|
/// <param name="d">A <see cref="T:System.Threading.SendOrPostCallback" /> object that wraps the delegate to be called when the operation ends. </param>
|
|
/// <param name="arg">An argument for the delegate contained in the <paramref name="d" /> parameter. </param>
|
|
/// <exception cref="T:System.InvalidOperationException">The <see cref="M:System.ComponentModel.AsyncOperation.PostOperationCompleted(System.Threading.SendOrPostCallback,System.Object)" /> method has been called previously for this task. </exception>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="d" /> is null. </exception>
|
|
// 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);
|
|
}
|
|
|
|
/// <summary>Ends the lifetime of an asynchronous operation.</summary>
|
|
/// <param name="d">A <see cref="T:System.Threading.SendOrPostCallback" /> object that wraps the delegate to be called when the operation ends. </param>
|
|
/// <param name="arg">An argument for the delegate contained in the <paramref name="d" /> parameter. </param>
|
|
/// <exception cref="T:System.InvalidOperationException">
|
|
/// <see cref="M:System.ComponentModel.AsyncOperation.OperationCompleted" /> has been called previously for this task. </exception>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="d" /> is null. </exception>
|
|
// 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;
|
|
}
|
|
}
|