Files
2026-06-04 11:42:34 +02:00

189 lines
7.6 KiB
C#

using System;
using System.Runtime.Serialization;
using System.Security;
namespace System.Threading
{
/// <summary>Manages the execution context for the current thread. This class cannot be inherited.</summary>
/// <filterpriority>2</filterpriority>
// Token: 0x0200060E RID: 1550
[Serializable]
public sealed class ExecutionContext : ISerializable
{
// Token: 0x060038A0 RID: 14496 RVA: 0x000C40BC File Offset: 0x000C22BC
internal ExecutionContext()
{
}
// Token: 0x060038A1 RID: 14497 RVA: 0x000C40C4 File Offset: 0x000C22C4
internal ExecutionContext(ExecutionContext ec)
{
if (ec._sc != null)
{
this._sc = new SecurityContext(ec._sc);
}
this._suppressFlow = ec._suppressFlow;
this._capture = true;
}
// Token: 0x060038A2 RID: 14498 RVA: 0x000C40FC File Offset: 0x000C22FC
[MonoTODO]
internal ExecutionContext(SerializationInfo info, StreamingContext context)
{
throw new NotImplementedException();
}
/// <summary>Captures the execution context from the current thread.</summary>
/// <returns>An <see cref="T:System.Threading.ExecutionContext" /> object representing the execution context for the current thread.</returns>
/// <filterpriority>1</filterpriority>
// Token: 0x060038A3 RID: 14499 RVA: 0x000C410C File Offset: 0x000C230C
public static ExecutionContext Capture()
{
ExecutionContext executionContext = Thread.CurrentThread.ExecutionContext;
if (executionContext.FlowSuppressed)
{
return null;
}
ExecutionContext executionContext2 = new ExecutionContext(executionContext);
if (SecurityManager.SecurityEnabled)
{
executionContext2.SecurityContext = SecurityContext.Capture();
}
return executionContext2;
}
/// <summary>Creates a copy of the current execution context.</summary>
/// <returns>An <see cref="T:System.Threading.ExecutionContext" /> object representing the current execution context.</returns>
/// <exception cref="T:System.InvalidOperationException">This context cannot be copied because it is used. Only newly captured contexts can be copied.</exception>
/// <filterpriority>2</filterpriority>
// Token: 0x060038A4 RID: 14500 RVA: 0x000C4150 File Offset: 0x000C2350
public ExecutionContext CreateCopy()
{
if (!this._capture)
{
throw new InvalidOperationException();
}
return new ExecutionContext(this);
}
/// <summary>Sets the specified <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with the logical context information needed to recreate an instance of the current execution context.</summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object to be populated with serialization information. </param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> structure representing the destination context of the serialization. </param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="info" /> is null. </exception>
/// <filterpriority>2</filterpriority>
// Token: 0x060038A5 RID: 14501 RVA: 0x000C416C File Offset: 0x000C236C
[MonoTODO]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException("info");
}
throw new NotImplementedException();
}
// Token: 0x17000AFF RID: 2815
// (get) Token: 0x060038A6 RID: 14502 RVA: 0x000C4184 File Offset: 0x000C2384
// (set) Token: 0x060038A7 RID: 14503 RVA: 0x000C41A4 File Offset: 0x000C23A4
internal SecurityContext SecurityContext
{
get
{
if (this._sc == null)
{
this._sc = new SecurityContext();
}
return this._sc;
}
set
{
this._sc = value;
}
}
// Token: 0x17000B00 RID: 2816
// (get) Token: 0x060038A8 RID: 14504 RVA: 0x000C41B0 File Offset: 0x000C23B0
// (set) Token: 0x060038A9 RID: 14505 RVA: 0x000C41B8 File Offset: 0x000C23B8
internal bool FlowSuppressed
{
get
{
return this._suppressFlow;
}
set
{
this._suppressFlow = value;
}
}
/// <summary>Indicates whether the flow of the execution context is currently suppressed.</summary>
/// <returns>true if the flow is suppressed; otherwise, false. </returns>
/// <filterpriority>1</filterpriority>
// Token: 0x060038AA RID: 14506 RVA: 0x000C41C4 File Offset: 0x000C23C4
public static bool IsFlowSuppressed()
{
return Thread.CurrentThread.ExecutionContext.FlowSuppressed;
}
/// <summary>Restores the flow of the execution context across asynchronous threads.</summary>
/// <exception cref="T:System.InvalidOperationException">The context flow cannot be restored because it is not being suppressed.</exception>
/// <filterpriority>1</filterpriority>
// Token: 0x060038AB RID: 14507 RVA: 0x000C41D8 File Offset: 0x000C23D8
public static void RestoreFlow()
{
ExecutionContext executionContext = Thread.CurrentThread.ExecutionContext;
if (!executionContext.FlowSuppressed)
{
throw new InvalidOperationException();
}
executionContext.FlowSuppressed = false;
}
/// <summary>Runs a method in a specified execution context on the current thread.</summary>
/// <param name="executionContext">The <see cref="T:System.Threading.ExecutionContext" /> to set.</param>
/// <param name="callback">A <see cref="T:System.Threading.ContextCallback" /> delegate that represents the method to be run in the provided execution context.</param>
/// <param name="state">The object to pass to the callback method.</param>
/// <exception cref="T:System.InvalidOperationException">
/// <paramref name="executionContext" /> is null.-or-<paramref name="executionContext" /> was not acquired through a capture operation. -or-<paramref name="executionContext" /> has already been used as the argument to a <see cref="M:System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object)" /> call.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060038AC RID: 14508 RVA: 0x000C4208 File Offset: 0x000C2408
[MonoTODO("only the SecurityContext is considered")]
public static void Run(ExecutionContext executionContext, ContextCallback callback, object state)
{
if (executionContext == null)
{
throw new InvalidOperationException(Locale.GetText("Null ExecutionContext"));
}
SecurityContext.Run(executionContext.SecurityContext, callback, state);
}
/// <summary>Suppresses the flow of the execution context across asynchronous threads.</summary>
/// <returns>An <see cref="T:System.Threading.AsyncFlowControl" /> structure for restoring the flow.</returns>
/// <exception cref="T:System.InvalidOperationException">The context flow is already suppressed.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
/// </PermissionSet>
// Token: 0x060038AD RID: 14509 RVA: 0x000C4230 File Offset: 0x000C2430
public static AsyncFlowControl SuppressFlow()
{
Thread currentThread = Thread.CurrentThread;
currentThread.ExecutionContext.FlowSuppressed = true;
return new AsyncFlowControl(currentThread, AsyncFlowControlType.Execution);
}
// Token: 0x040016E8 RID: 5864
private SecurityContext _sc;
// Token: 0x040016E9 RID: 5865
private bool _suppressFlow;
// Token: 0x040016EA RID: 5866
private bool _capture;
}
}