public static async Task <LockAsync> Create(object lockPointObject, bool keepQueueIfEmpty = true) { var lockAsync = new LockAsync(keepQueueIfEmpty); await lockAsync.Lock(lockPointObject); return(lockAsync); }
private async void StartupOrchestratorAsync(StartupInfo e) { DebugWrite(e.ToString()); using (var locker = await LockAsync.Create(startupLocker)) { if (e.ThisIsFirstStart) { // handle launch await OperationWrapperAsync(BootstrapperStates.Launching, async() => { var window = DoShowSplash(e); var root = await DoCreateRootElementAsync(e); await Task.Delay(1); if (e.ThisIsPrelaunch) { await OperationWrapperAsync(BootstrapperStates.Prelaunching, async() => { try { await OnStartAsync(e); } catch { Debugger.Break(); throw; } }, BootstrapperStates.Prelaunched); } else { if (!await DoRestoreWhenResumingAsync(e)) { await OperationWrapperAsync(BootstrapperStates.Starting, async() => { try { await OnStartAsync(e); } catch { Debugger.Break(); throw; } }, BootstrapperStates.Started); } } // do some one-time things DoSetupResuming(e); DoSetupSuspending(e); DoSetupTitleBar(e); DoSetupBackButton(e); await DoSetupExtendedSessionAsync(e); DoHideSplash(e, root, window); }, BootstrapperStates.Launched); } else { // handle activate await OperationWrapperAsync(BootstrapperStates.Activating, async() => { await OnStartAsync(e); }, BootstrapperStates.Activated); } } }