示例#1
0
        private static async Task <Tuple <ExtendedSplashScreenContent, TaskCompletionSource <object> > > CreateExtendedSplashScreenContentAsync(Window hostWindow, AppStartInfo info)
        {
            // 创建创建扩展启动屏幕方法为 null。
            if (info.ExtendedSplashScreen == null)
            {
                return(Tuple.Create <ExtendedSplashScreenContent, TaskCompletionSource <object> >(null, null));
            }

            ExtendedSplashScreenContent   extendedSplashScreenContent = null;
            TaskCompletionSource <object> extendedSplashScreenTcs     = null;
            await hostWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                extendedSplashScreenContent = info.ExtendedSplashScreen();
                if (extendedSplashScreenContent != null)
                {
                    extendedSplashScreenTcs = new TaskCompletionSource <object>();

                    EventHandler extendedSplashScreenFinishedHandler = null;
                    extendedSplashScreenFinishedHandler = delegate
                    {
                        extendedSplashScreenContent.Finished -= extendedSplashScreenFinishedHandler;
                        extendedSplashScreenTcs.SetResult(null);
                    };
                    extendedSplashScreenContent.Finished += extendedSplashScreenFinishedHandler;
                }
            });

            return(Tuple.Create <ExtendedSplashScreenContent, TaskCompletionSource <object> >(extendedSplashScreenContent, extendedSplashScreenTcs));
        }