WindowsThreadingHelper

Ecng.Interop

Provides helper methods to run code on threads with specific apartment states.

Métodos

InvokeAsSTA
public static void InvokeAsSTA(Action action)
WindowsThreadingHelper.InvokeAsSTA(action)

Invokes the specified action on a new STA (single-threaded apartment) thread.

action
The action to invoke.
InvokeAsSTA``1
public static T InvokeAsSTA<T>(Func<T> func)
result = WindowsThreadingHelper.InvokeAsSTA(func)

Invokes the specified function on a new STA (single-threaded apartment) thread and returns a result.

func
The function to invoke.

Retorna: The result returned by the function.

MTA
public static Thread MTA(Thread thread)
result = WindowsThreadingHelper.MTA(thread)

Sets the apartment state of the specified thread to multi-threaded apartment (MTA).

thread
The thread to set the apartment state for.

Retorna: The same thread with the updated apartment state.

STA
public static Thread STA(Thread thread)
result = WindowsThreadingHelper.STA(thread)

Sets the apartment state of the specified thread to single-threaded apartment (STA).

thread
The thread to set the apartment state for.

Retorna: The same thread with the updated apartment state.