Ejemplo n.º 1
0
        private static void Start(App app, AppStartCallback start, AppStopCallback stop)
        {
            CultureInfo.CurrentCulture = new CultureInfo("en-us");

            string directory = AppDomain.CurrentDomain.BaseDirectory;

            if (app is Rest rest)
            {
                var hostBuilder = Host.CreateDefaultBuilder(Environment.GetCommandLineArgs());
                hostBuilder.ConfigureWebHostDefaults(builder =>
                {
                    builder.UseStartup(delegate(WebHostBuilderContext c)
                    {
                        return(rest);
                    });
                });

                // start app
                start(directory);

                rest.Started += () =>
                {
                    // start ho
                    var cancel   = new CancellationTokenSource();
                    var hostTask = hostBuilder.Build().RunAsync(cancel.Token);

                    // bind host to app
                    app.BindProcess(hostTask);
                    app.BindProcess(cancel);
                };

                app.Wait();
            }
            else
            {
                if (Environment.UserInteractive)
                {
                    start(directory);

                    if (app != null)
                    {
                        app.Wait();
                    }
                }
                else
                {
                }
            }
        }
Ejemplo n.º 2
0
 public static void Start(AppStartCallback start, AppStopCallback stop) => Start(null, start, stop);
Ejemplo n.º 3
0
 public static void Start(AppStartCallback start) => Start(null, start, null);