JoinableTaskFactory.Run 메서드

정의

오버로드

Run(Func<Task>)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

Run(Func<Task>, JoinableTaskCreationOptions)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

Run<T>(Func<Task<T>>, JoinableTaskCreationOptions)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

Run<T>(Func<Task<T>>)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

Run(Func<Task>)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

public:
 void Run(Func<System::Threading::Tasks::Task ^> ^ asyncMethod);
public void Run (Func<System.Threading.Tasks.Task> asyncMethod);
member this.Run : Func<System.Threading.Tasks.Task> -> unit
Public Sub Run (asyncMethod As Func(Of Task))

매개 변수

asyncMethod
Func<Task>

실행할 비동기 메서드입니다.

설명

대리자가 throw한 예외는 원래 형식에서 이 메서드의 호출자에게 다시 throw됩니다.

대리자를 생성 대기에서 다시 시작하면 기본 동작은 일반 비동기 메서드 실행처럼 원래 컨텍스트에서 다시 시작하는 것입니다. 예를 들어 호출자가 기본 스레드에 있는 경우 기본 스레드에서 대기한 후에 실행이 다시 시작되지만 스레드 풀 스레드에서 시작된 경우 스레드 풀 스레드에서 다시 시작됩니다.

// On threadpool or Main thread, this method will block
// the calling thread until all async operations in the
// delegate complete.
joinableTaskFactory.Run(async delegate {
    // still on the threadpool or Main thread as before.
    await OperationAsync();
    // still on the threadpool or Main thread as before.
    await Task.Run(async delegate {
         // Now we're on a threadpool thread.
         await Task.Yield();
         // still on a threadpool thread.
    });
    // Now back on the Main thread (or threadpool thread if that's where we started).
});

적용 대상

Run(Func<Task>, JoinableTaskCreationOptions)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

public:
 void Run(Func<System::Threading::Tasks::Task ^> ^ asyncMethod, Microsoft::VisualStudio::Threading::JoinableTaskCreationOptions creationOptions);
public void Run (Func<System.Threading.Tasks.Task> asyncMethod, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions);
member this.Run : Func<System.Threading.Tasks.Task> * Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions -> unit
Public Sub Run (asyncMethod As Func(Of Task), creationOptions As JoinableTaskCreationOptions)

매개 변수

asyncMethod
Func<Task>

실행할 비동기 메서드입니다.

creationOptions
JoinableTaskCreationOptions

작업의 동작을 사용자 지정하는 데 사용할 JoinableTaskCreationOptions입니다.

적용 대상

Run<T>(Func<Task<T>>, JoinableTaskCreationOptions)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

public:
generic <typename T>
 T Run(Func<System::Threading::Tasks::Task<T> ^> ^ asyncMethod, Microsoft::VisualStudio::Threading::JoinableTaskCreationOptions creationOptions);
public T Run<T> (Func<System.Threading.Tasks.Task<T>> asyncMethod, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions);
member this.Run : Func<System.Threading.Tasks.Task<'T>> * Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions -> 'T
Public Function Run(Of T) (asyncMethod As Func(Of Task(Of T)), creationOptions As JoinableTaskCreationOptions) As T

형식 매개 변수

T

비동기 작업에서 반환된 값의 형식입니다.

매개 변수

asyncMethod
Func<Task<T>>

실행할 비동기 메서드입니다.

creationOptions
JoinableTaskCreationOptions

작업의 동작을 사용자 지정하는 데 사용할 JoinableTaskCreationOptions입니다.

반환

T

에서 반환 asyncMethod한 작업의 결과입니다.

설명

대리자가 throw한 예외는 원래 형식에서 이 메서드의 호출자에게 다시 throw됩니다.

대리자를 생성 대기에서 다시 시작하면 기본 동작은 일반 비동기 메서드 실행처럼 원래 컨텍스트에서 다시 시작하는 것입니다. 예를 들어 호출자가 기본 스레드에 있는 경우 기본 스레드에서 대기한 후에 실행이 다시 시작되지만 스레드 풀 스레드에서 시작된 경우 스레드 풀 스레드에서 다시 시작됩니다.

// On threadpool or Main thread, this method will block
// the calling thread until all async operations in the
// delegate complete.
joinableTaskFactory.Run(async delegate {
    // still on the threadpool or Main thread as before.
    await OperationAsync();
    // still on the threadpool or Main thread as before.
    await Task.Run(async delegate {
         // Now we're on a threadpool thread.
         await Task.Yield();
         // still on a threadpool thread.
    });
    // Now back on the Main thread (or threadpool thread if that's where we started).
});

적용 대상

Run<T>(Func<Task<T>>)

호출 스레드를 동기적으로 차단하는 동안 지정된 비동기 메서드를 실행하여 완료합니다.

public:
generic <typename T>
 T Run(Func<System::Threading::Tasks::Task<T> ^> ^ asyncMethod);
public T Run<T> (Func<System.Threading.Tasks.Task<T>> asyncMethod);
member this.Run : Func<System.Threading.Tasks.Task<'T>> -> 'T
Public Function Run(Of T) (asyncMethod As Func(Of Task(Of T))) As T

형식 매개 변수

T

비동기 작업에서 반환된 값의 형식입니다.

매개 변수

asyncMethod
Func<Task<T>>

실행할 비동기 메서드입니다.

반환

T

에서 반환 asyncMethod한 작업의 결과입니다.

설명

대리자가 throw한 예외는 원래 형식에서 이 메서드의 호출자에게 다시 throw됩니다.

대리자를 생성 대기에서 다시 시작하면 기본 동작은 일반 비동기 메서드 실행처럼 원래 컨텍스트에서 다시 시작하는 것입니다. 예를 들어 호출자가 기본 스레드에 있는 경우 기본 스레드에서 대기한 후에 실행이 다시 시작되지만 스레드 풀 스레드에서 시작된 경우 스레드 풀 스레드에서 다시 시작됩니다.

예제는 Run(Func<Task>) 오버로드 설명서를 참조하세요.

적용 대상