ContextCallback 委托

定义

表示要在新的上下文中调用的方法。

C#
public delegate void ContextCallback(object state);
C#
public delegate void ContextCallback(object? state);
C#
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void ContextCallback(object state);

参数

state
Object

一个对象,包含回调方法在每次执行时要使用的信息。

属性

注解

ContextCallbackExecutionContext.RunSecurityContext.Run 方法使用。 ContextCallback 表示在提供的上下文中要运行的方法。 完成方法执行后,上下文将还原到其以前的状态。

通过将回调方法传递给 ContextCallback 构造函数来创建委托。 方法必须具有此处所示的签名。

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。

适用于

产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0