SecurityContext.Run(SecurityContext, ContextCallback, Object) 메서드

정의

현재 스레드의 지정한 보안 컨텍스트에서 지정한 메서드를 실행합니다.

public:
 static void Run(System::Security::SecurityContext ^ securityContext, System::Threading::ContextCallback ^ callback, System::Object ^ state);
public static void Run (System.Security.SecurityContext securityContext, System.Threading.ContextCallback callback, object state);
[System.Security.SecurityCritical]
public static void Run (System.Security.SecurityContext securityContext, System.Threading.ContextCallback callback, object state);
static member Run : System.Security.SecurityContext * System.Threading.ContextCallback * obj -> unit
[<System.Security.SecurityCritical>]
static member Run : System.Security.SecurityContext * System.Threading.ContextCallback * obj -> unit
Public Shared Sub Run (securityContext As SecurityContext, callback As ContextCallback, state As Object)

매개 변수

securityContext
SecurityContext

설정할 보안 컨텍스트입니다.

callback
ContextCallback

지정한 보안 컨텍스트에서 실행할 메서드를 나타내는 대리자입니다.

state
Object

콜백 메서드로 전달할 개체입니다.

특성

예외

securityContext이(가) null인 경우

또는 캡처 작업을 통해 securityContext를 가져오지 않은 경우

또는 securityContext가 이미 Run(SecurityContext, ContextCallback, Object) 메서드 호출에 대한 인수로 사용된 경우

.NET 5 이상(.NET Core 포함): 모든 경우에.

예제

다음 코드 예제에서는 메서드를 사용하여 Run 지정된 보안 컨텍스트에서 메서드를 실행하는 방법을 보여줍니다.

using System;
using System.Security;
using System.Threading;

class Test
{
    static void Main()
    {
        SecurityContext.Run(SecurityContext.Capture(), 
            new ContextCallback(Callback), "Hello world.");
    }
    static void Callback(object o)
    {
        Console.WriteLine(o);
    }
}
Imports System.Security
Imports System.Threading



Class Test
    
    Shared Sub Main() 
        Dim cCallBack As New ContextCallback(AddressOf Callback)
        SecurityContext.Run(SecurityContext.Capture(), cCallBack, "Hello world.")
    End Sub
    
    Shared Sub Callback(ByVal o As Object) 
        Console.WriteLine(o)
    
    End Sub
End Class

설명

메서드 호출이 완료되면 현재 스레드의 보안 컨텍스트가 이전 상태로 반환됩니다.

적용 대상