/// <summary> /// This is the main function that loads the game engine, /// executes the user code that depends on it, /// and then shuts down the game engine. /// </summary> /// <param name="args">Command line arguments</param> /// <returns>Zero if execution was successful, /// or failure codes normally returned /// by application's main entry point.</returns> public int Run(string[] args) { int returnCode = 1; this.mOverrideUserDataPath = null; string installedGameUserDataDir = App.GetInstalledGameUserDataDir(); SharedInitialization.AddGimexSupport(); Panel panel1 = new Panel(); if (!string.IsNullOrEmpty(installedGameUserDataDir)) { string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); this.mOverrideUserDataPath = Path.Combine(folderPath, installedGameUserDataDir); } if (!App.InitApp("", "", panel1.Width, panel1.Height, IntPtr.Zero, 0, panel1.Handle, true, null, this.mOverrideUserDataPath)) { throw new Exception("Failed to initialize game engine"); } App.StartProcessMessages(); returnCode = this.Execute(args); App.Shutdown(); return(returnCode); }
public async void Run(IBackgroundTaskInstance taskInstance) { SharedInitialization.Initialize(); InitializeUWP.Initialize(); taskInstance.Canceled += TaskInstance_Canceled; var deferral = taskInstance.GetDeferral(); try { var accounts = await AccountsManager.GetAllAccounts(); var cancellationToken = _cancellationTokenSource.Token; try { cancellationToken.ThrowIfCancellationRequested(); foreach (var a in accounts) { var data = await AccountDataStore.Get(a.LocalAccountId); cancellationToken.ThrowIfCancellationRequested(); await TileHelper.UpdateTileNotificationsForAccountAsync(a, data); cancellationToken.ThrowIfCancellationRequested(); } } catch (OperationCanceledException) { } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } // TODO: Re-schedule toast notifications? finally { deferral.Complete(); } }
public async void Run(IBackgroundTaskInstance taskInstance) { SharedInitialization.Initialize(); InitializeUWP.Initialize(); taskInstance.Canceled += TaskInstance_Canceled; var deferral = taskInstance.GetDeferral(); try { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; long accountId = UWPPushExtension.GetAccountIdFromRawNotification(notification); if (accountId == 0) { return; } AccountDataItem account = (await AccountsManager.GetAllAccounts()).FirstOrDefault(i => i.AccountId == accountId); if (account == null) { return; } var cancellationToken = _cancellationTokenSource.Token; try { cancellationToken.ThrowIfCancellationRequested(); var result = await Sync.SyncAccountAsync(account); // If succeeded if (result != null && result.Error == null) { // Flag as updated by background task so foreground app can update data AccountDataStore.SetUpdatedByBackgroundTask(); } // Need to wait for the tile/toast tasks to finish before we release the deferral if (result != null && result.SaveChangesTask != null) { await result.SaveChangesTask.WaitForAllTasksAsync(); } } catch (OperationCanceledException) { } // Wait for the calendar integration to complete await AppointmentsExtension.Current?.GetTaskForAllCompleted(); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } finally { deferral.Complete(); } }
/// <summary> /// Scene Initialization. /// The Game Engine, Rendering Panel, Scene Manager, Text Renderer, /// and other game engine dependent components /// are initialized here. /// </summary> /// <param name="splash">A splash form for displaying initialization messages.</param> /// <returns>True if all components were successfully initialized, /// False otherwise</returns> public bool Init(ISplashForm splash) { if (this.mRenderingPanel == null) { this.mRenderingPanel = new RenderPanelEx(); //return false; } if (splash != null) { splash.Message = "Initializing Game Engine..."; } string overrideUserDataPath = null; string installedGameUserDataDir = App.GetInstalledGameUserDataDir(); SharedInitialization.AddGimexSupport(); if (!string.IsNullOrEmpty(installedGameUserDataDir)) { string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); overrideUserDataPath = Path.Combine(folderPath, installedGameUserDataDir); } this.mStopWatch.Start(); float startTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; if (!App.InitApp("", "", this.mRenderingPanel.Width, this.mRenderingPanel.Height, IntPtr.Zero, 0, this.mRenderingPanel.Handle, true, null, overrideUserDataPath)) //if (!App.InitApp("", "", this.mRenderPanel.Width, this.mRenderPanel.Height, IntPtr.Zero, 0, this.mRenderPanel.Handle, true, null, App.StartupServices.ServicesFull, null, overrideUserDataPath, true)) { //throw new Exception("Failed to initialise CSHost"); return(false); } float endTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; this.mAppInitTime = endTime - startTime; App.StartProcessMessages(); this.mRenderingPanel.AttachToNativeCanvas(); this.mRenderingPanel.Resize += new EventHandler(RenderPanel_Resize); GameObjectFactory.Init(); SharedInitialization.RegisterResourceFactories(); if (splash != null) { splash.Message = "Initializing Scene..."; } this.mScene = new SceneManager(); if (!this.mScene.Init()) { return(false); } CameraTuning.InitializeTuningData(); this.InitializeScene(); ScriptCoreManager.Initialize(); if (splash != null) { splash.Message = "Reticulating Splines..."; } startTime = this.mStopWatch.GetElapsedMilliSecs() / 1000f; this.mSceneInitTime = startTime - endTime; this.mStopWatch.Stop(); this.mStopWatch.Reset(); this.mStopWatch.Start(); this.mTimeAtLastFrame = 0f; this.mTextRenderer = new Sims3.CSHost.Renderer.TextRenderer(); this.mGraphicsInitialized = true; return(this.InitExtra()); }