public Task PostAsync(Action action) { var tcs = new TaskCompletionSource <bool>(); if (EcoreMainloop.IsMainThread) { try { action?.Invoke(); tcs.SetResult(true); } catch (Exception ex) { tcs.SetException(ex); } } else { EcoreMainloop.PostAndWakeUp(() => { try { action?.Invoke(); tcs.SetResult(true); } catch (Exception ex) { tcs.SetException(ex); } }); } return(tcs.Task); }
public async Task PostAsync(Func <Task> action) { var tcs = new TaskCompletionSource <bool>(); if (EcoreMainloop.IsMainThread) { try { await action?.Invoke(); tcs.SetResult(true); } catch (Exception ex) { tcs.SetException(ex); } } else { EcoreMainloop.PostAndWakeUp(async() => { try { await action?.Invoke(); tcs.SetResult(true); } catch (Exception ex) { tcs.SetException(ex); } }); } await tcs.Task; }
public TizenHost(Func <WinUI.Application> appBuilder, string[] args = null) { Elementary.Initialize(); Elementary.ThemeOverlay(); _current = this; _appBuilder = appBuilder; _args = args; _args ??= Environment .GetCommandLineArgs() .Skip(1) .ToArray(); bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback) { EcoreMainloop.PostAndWakeUp(() => callback()); return(true); } Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative; Windows.UI.Core.CoreDispatcher.DispatchOverride = (d) => EcoreMainloop.PostAndWakeUp(d); Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread; _tizenApplication = new TizenApplication(this); _tizenApplication.Run(_args); }
static void PlatformBeginInvokeOnMainThread(Action action) { if (PlatformIsMainThread) { action(); } else { EcoreMainloop.PostAndWakeUp(action); } }
public IDisposable Schedule <TState>(TState state, Func <IScheduler, TState, IDisposable> action) { var innerDisp = new SingleAssignmentDisposable(); EcoreMainloop.PostAndWakeUp(() => { if (!innerDisp.IsDisposed) { innerDisp.Disposable = action(this, state); } }); return(innerDisp); }
public static async void PostAndWakeUp(Action action) { await _mutex.WaitAsync().ConfigureAwait(false); try { EcoreMainloop.PostAndWakeUp(action); } finally { _mutex.Release(); } }
public TizenHost(Func <WinUI.Application> appBuilder, string[]?args = null) { Elementary.Initialize(); Elementary.ThemeOverlay(); _current = this; _appBuilder = appBuilder; Windows.UI.Core.CoreDispatcher.DispatchOverride = (d) => EcoreMainloop.PostAndWakeUp(d); Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread; _tizenApplication = new TizenApplication(this); _tizenApplication.Run(args); }
public TizenHost(Func <WinUI.Application> appBuilder) { Elementary.Initialize(); Elementary.ThemeOverlay(); _current = this; _appBuilder = appBuilder; Windows.UI.Core.CoreDispatcher.DispatchOverride = (d) => EcoreMainloop.PostAndWakeUp(d); Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread; _tizenApplication = new TizenApplication(this); _tizenApplication.Run(Environment.GetCommandLineArgs()); }
/// <summary> /// Creates a WpfHost element to host a Uno-Skia into a WPF application. /// </summary> /// <remarks> /// If args are omitted, those from Environment.GetCommandLineArgs() will be used. /// </remarks> public TizenHost(Func <WinUI.Application> appBuilder, string[] args = null) { Elementary.Initialize(); Elementary.ThemeOverlay(); _current = this; _appBuilder = appBuilder; _args = args; _args ??= Environment .GetCommandLineArgs() .Skip(1) .ToArray(); Windows.UI.Core.CoreDispatcher.DispatchOverride = (d) => EcoreMainloop.PostAndWakeUp(d); _tizenApplication = new TizenApplication(this); _tizenApplication.Run(_args); }