C# Class Exrin.Common.ThreadHelper

Afficher le fichier Open project: exrin/Exrin

Méthodes publiques

Méthode 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

Méthode Description
RunOnUIThreadHelper ( System.Action action ) : Task
RunOnUIThreadHelper ( Func action ) : Task
RunSync ( Func task ) : void

Method Details

Init() public static méthode

public static Init ( SynchronizationContext uiContext ) : void
uiContext System.Threading.SynchronizationContext
Résultat void

IsOnUIThread() public static méthode

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
Résultat bool

RunOnUIThread() public static méthode

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
Résultat void

RunOnUIThread() public static méthode

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
Résultat void

RunOnUIThreadAsync() public static méthode

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
Résultat Task