Opc.Ua.SampleServer.App.OnLaunched C# (CSharp) Méthode

OnLaunched() protected méthode

Invoked when the application is launched normally by the end user. Other entry points will be used such as when the application is launched to open a specific file.
protected OnLaunched ( LaunchActivatedEventArgs args ) : void
args Windows.ApplicationModel.Activation.LaunchActivatedEventArgs
Résultat void
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();
            application.ApplicationName = "UA Sample Server";
            application.ApplicationType = ApplicationType.Server;
            application.ConfigSectionName = "Opc.Ua.SampleServer";

            // helper to let Opc.Ua Utils find the localFolder in the environment
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            Utils.DefaultLocalFolder = localFolder.Path;

            // set empty page for MessageDlg
            Window.Current.Content = new ServerPage();

            // Ensure the current window is active
            Window.Current.Activate();

            // Allow the current window to activate since the stack initialization below can take some time
            // and the app can be terminated by the runtime if this takes too long
            await Task.Delay(1);

            try
            {
                // load the application configuration.
                await application.LoadApplicationConfiguration(false);

                // check the application certificate.
                await application.CheckApplicationInstanceCertificate(false, 0);

                // start the server.
                await application.Start(new Opc.Ua.Sample.SampleServer());

                // run the application interactively.
                Window.Current.Content = new ServerPage(application);
            }
            catch (Exception ex)
            {
                Utils.Trace("Exception:" + ex.Message);
                MessageDlg dialog = new MessageDlg(ex.Message);
                await dialog.ShowAsync();
                Application.Current.Exit();
            }
        }