C# Class Exrin.Common.ThreadHelper

Datei anzeigen Open project: exrin/Exrin

Public Methods

Method Description
Init ( SynchronizationContext uiContext ) : void
IsOnUIThread ( SynchronizationContext context ) : bool

Determines if the current synchronization context is the UI Thread

RunOnUIThread ( System.Action action ) : void

Will run the Action on the UI Thread. PERFORMANCE: Do not use in a loop. Context switching can cause significant performance degradation. Call this as infrequently as possible.

RunOnUIThread ( Func action ) : void

Will run the Func on the UI Thread. PERFORMANCE: Do not use in a loop. Context switching can cause significant performance degradation. Call this as infrequently as possible.

RunOnUIThreadAsync ( Func action ) : Task

Will run the Func on the UIThread asynchronously. PERFORMANCE: Do not use in a loop. Context switching can cause significant performance degradation. Call this as infrequently as possible.

Private Methods

Method Description
RunOnUIThreadHelper ( System.Action action ) : Task
RunOnUIThreadHelper ( Func action ) : Task
RunSync ( Func task ) : void

Method Details

Init() public static method

public static Init ( SynchronizationContext uiContext ) : void
uiContext System.Threading.SynchronizationContext
return void

IsOnUIThread() public static method

Determines if the current synchronization context is the UI Thread
public static IsOnUIThread ( SynchronizationContext context ) : bool
context System.Threading.SynchronizationContext SynchronizationContext you want to compare with the UIThread SynchronizationContext
return bool

RunOnUIThread() public static method

Will run the Action on the UI Thread. PERFORMANCE: Do not use in a loop. Context switching can cause significant performance degradation. Call this as infrequently as possible.
public static RunOnUIThread ( System.Action action ) : void
action System.Action
return void

RunOnUIThread() public static method

Will run the Func on the UI Thread. PERFORMANCE: Do not use in a loop. Context switching can cause significant performance degradation. Call this as infrequently as possible.
public static RunOnUIThread ( Func action ) : void
action Func
return void

RunOnUIThreadAsync() public static method

Will run the Func on the UIThread asynchronously. PERFORMANCE: Do not use in a loop. Context switching can cause significant performance degradation. Call this as infrequently as possible.
public static RunOnUIThreadAsync ( Func action ) : Task
action Func
return Task