Beispiel #1
0
        } // End Function RemoveFlag

        private static void RunInteractive(string[] args)
        {
            DasMulli.Win32.ServiceUtils.IWin32Service service =
                new TestWin32Service(RemoveFlag(args, INTERACTIVE));

            service.Start(new string[0], () => { });
            System.Console.WriteLine("Running interactively, press enter to stop.");
            System.Console.ReadLine();
            service.Stop();
        }
Beispiel #2
0
        private static void RunAsService(string[] args)
        {
            DasMulli.Win32.ServiceUtils.IWin32Service service =
                new TestWin32Service(RemoveFlag(args, RUN_AS_SERVICE));


            if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
            {
                DasMulli.Win32.ServiceUtils.Win32ServiceHost serviceHost =
                    new DasMulli.Win32.ServiceUtils.Win32ServiceHost(service);
                serviceHost.Run();
            }
            else if (System.Environment.OSVersion.Platform == System.PlatformID.Unix) // includes Mac
            {
                service.Start(new string[0], () => { });
            }
            else
            {
                System.Console.WriteLine("Unknown operating system.");
                System.Console.WriteLine("Attempting to start service.");
                service.Start(new string[0], () => { }); // ?
            }
        }