Share via


ControlledExecution.Run(Action, CancellationToken) 메서드

정의

주의

ControlledExecution.Run method may corrupt the process and should not be used in production code.

비동기적으로 중단될 수 있는 코드를 실행합니다.

public:
 static void Run(Action ^ action, System::Threading::CancellationToken cancellationToken);
[System.Obsolete("ControlledExecution.Run method may corrupt the process and should not be used in production code.", DiagnosticId="SYSLIB0046", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static void Run (Action action, System.Threading.CancellationToken cancellationToken);
[<System.Obsolete("ControlledExecution.Run method may corrupt the process and should not be used in production code.", DiagnosticId="SYSLIB0046", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member Run : Action * System.Threading.CancellationToken -> unit
Public Shared Sub Run (action As Action, cancellationToken As CancellationToken)

매개 변수

action
Action

실행할 코드를 나타내는 대리자입니다.

cancellationToken
CancellationToken

실행을 중단하는 데 사용할 수 있는 취소 토큰입니다.

특성

예외

메서드는 이 플랫폼에서 지원되지 않습니다.

action 인수가 null인 경우

현재 스레드가 이미 메서드를 실행하고 있습니다 Run(Action, CancellationToken) .

실행이 중단되었습니다.

설명

이 메서드를 사용하면 해당 코드를 실행하는 스레드에서 예외를 throw하여 비협조적인 방식으로 임의 관리 코드를 중단할 수 있습니다. 코드에서 예외를 catch할 수 있지만 실행 흐름이 메서드로 반환 ControlledExecution.Run 될 때까지 블록 끝에서 catch 다시 throw됩니다.

코드 실행이 즉시 또는 전혀 중단되지는 않습니다. 예를 들어 스레드가 관리되지 않는 코드 또는 catch 중단 프로시저의 일부로 호출된 및 finally 블록을 실행하다가 중단을 무기한 지연하는 경우 이러한 상황이 발생할 수 있습니다. 또한 스레드가 현재 또는 finally 블록을 실행하는 catch 경우 실행이 즉시 중단되지 않을 수 있습니다.

예기치 않은 위치에서 코드를 중단하면 프로세스의 데이터 구조 상태가 손상되어 예측할 수 없는 결과가 발생할 수 있습니다. 이러한 이유로 이 메서드는 프로덕션 코드에서 사용해서는 안 되며 호출하면 컴파일 시간 경고가 생성됩니다.

적용 대상