Example #1
0
 internal void RemoveSecondaryWindow(WindowFrameService frameService)
 {
     // Shell does not allow killing the main window.
     if (m_mainViewId != frameService.GetViewId())
     {
         RemoveWindowFromMap(frameService.GetViewId());
     }
 }
Example #2
0
 internal void RemoveWindow(WindowFrameService frameService)
 {
     // Shell does not allow killing the main window.
     if (m_mainViewId != frameService.GetViewId())
     {
         _ = HandleViewReleaseAndRemoveWindowFromMap(frameService);
     }
 }
Example #3
0
 private void AddWindowToMap(WindowFrameService frameService)
 {
     m_windowsMapLock.EnterWriteLock();
     try
     {
         m_secondaryWindows[frameService.GetViewId()] = frameService;
         TraceLogger.GetInstance().UpdateWindowCount(Convert.ToUInt64(m_secondaryWindows.Count));
     }
     finally
     {
         m_windowsMapLock.ExitWriteLock();
     }
 }
Example #4
0
        private async Task HandleViewReleaseAndRemoveWindowFromMap(WindowFrameService frameService)
        {
            WeakReference weak = new WeakReference(this);

            // Unregister the event handler of the Main Page
            var frame    = (Window.Current.Content as Frame);
            var mainPage = (frame.Content as MainPage);

            mainPage.UnregisterEventHandlers();

            await frameService.HandleViewRelease();

            await Task.Run(() =>
            {
                var that = weak.Target as App;
                that.RemoveWindowFromMap(frameService.GetViewId());
            }).ConfigureAwait(false /* task_continuation_context::use_arbitrary() */);
        }
Example #5
0
        private async Task HandleViewReleaseAndRemoveWindowFromMap(WindowFrameService frameService)
        {
            WeakReference weak = new WeakReference(this);

            // Unregister the event handler of the Main Page
            var frame    = (Window.Current.Content as Frame);
            var mainPage = (frame.Content as MainPage);

            mainPage.UnregisterEventHandlers();

            // TODO, remove this workaround after Mica fix
            // Workaround app crash caused by Mica in multi-view case.
            Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(mainPage, false);

            await frameService.HandleViewRelease();

            await Task.Run(() =>
            {
                var that = weak.Target as App;
                that.RemoveWindowFromMap(frameService.GetViewId());
            }).ConfigureAwait(false /* task_continuation_context::use_arbitrary() */);
        }