Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
UiDispatcher.cs
1namespace Gondwana;
2
19public sealed class UiDispatcher : IUiDispatcher
20{
21 private readonly SynchronizationContext _uiContext;
22 private readonly int _uiThreadId;
23
40 public UiDispatcher(SynchronizationContext uiContext)
41 {
42 _uiContext = uiContext ?? throw new ArgumentNullException(nameof(uiContext));
43 _uiThreadId = Environment.CurrentManagedThreadId;
44 }
45
59 public bool IsOnUIThread => Environment.CurrentManagedThreadId == _uiThreadId;
60
83 public void Post(Action action) => _uiContext.Post(_ => action(), null);
84
110 public void Send(Action action)
111 {
112 if (IsOnUIThread) { action(); return; }
113 _uiContext.Send(_ => action(), null);
114 }
115}
void Post(Action action)
Asynchronously posts an action to be executed on the UI thread. This method queues the action and ret...
bool IsOnUIThread
Gets a value indicating whether the current thread is the UI thread to which this dispatcher is bound...
UiDispatcher(SynchronizationContext uiContext)
Initializes a new instance of the UiDispatcher class with the specified synchronization context.
void Send(Action action)
Synchronously sends an action to be executed on the UI thread. If already on the UI thread,...
Defines a contract for dispatching actions to the UI thread in a thread-safe manner....