Executes tasks in GUI thread.
Namespace: Dapfor.Wpf.ThreadingAssembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)
Syntax
C# |
---|
public sealed class GuiDispatcher : IDispatcher |
Visual Basic |
---|
Public NotInheritable Class GuiDispatcher Implements IDispatcher |
Visual C++ |
---|
public ref class GuiDispatcher sealed : IDispatcher |
F# |
---|
[<SealedAttribute>] type GuiDispatcher = class interface IDispatcher end |
Remarks
Following example demonstrates how to use dispatcher:
Copy | |
---|---|
public partial class SomeWindow : Window { private readonly IDispatcher dispatcher; public SomeWindow() { InitializeComponent(); this.dispatcher = new GuiDispatcher(this.Dispatcher); } //This method can be called from non-GUI thread private void DrawTextInControl(string text) { if (dispatcher.SynchronizationRequired) { //Create a task that will be executed in dispatcher thread without blocking the calling thread dispatcher.Dispatch(new DelegateTask(delegate { this.Content = text; })); } else { //This is the GUI thread. this.Content = text; } } } |