Exemple #1
0
    public static void Main(string [] args)
    {
        // To configure this application to run as a service, run these commands as an admin:
        // sc create SERVICE_NAME type= own start= auto binPath= "FULL_PATH_TO_EXE\IpcServer.exe /service"
        // sc failure SERVICE_NAME reset= 86400 actions= restart/60000/restart/60000/restart/60000
        // sc start SERVICE_NAME
        //
        // Other useful commands
        // sc stop SERVICE_NAME
        // sc delete SERVICE_NAME

        if (args.Length > 0 && args[0] == "/service") {
            // Run as a service application
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new DemoService() };
            ServiceBase.Run(ServicesToRun);
        }
        else {
            // Run as a Windows console application
            DemoIpcServer m_server = new DemoIpcServer();
            m_server.Start();

            // Since all the requests are issued asynchronously, the constructors are likely to return
            // before all the requests are complete. The call below stops the application from terminating
            // until we see all the responses displayed.
            Thread.Sleep(1000);
            Console.WriteLine("\nPress return to shutdown server");
            Console.ReadLine();

            m_server.Stop();

            Console.WriteLine("\nComplete! Press return to exit program");
            Console.ReadLine();
        }
    }
Exemple #2
0
    public static void Main(string [] args)
    {
        // To configure this application to run as a service, run these commands as an admin:
        // sc create SERVICE_NAME type= own start= auto binPath= "FULL_PATH_TO_EXE\IpcServer.exe /service"
        // sc failure SERVICE_NAME reset= 86400 actions= restart/60000/restart/60000/restart/60000
        // sc start SERVICE_NAME
        //
        // Other useful commands
        // sc stop SERVICE_NAME
        // sc delete SERVICE_NAME


        if (args.Length > 0 && args[0] == "/service")
        {
            // Run as a service application
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] { new DemoService() };
            ServiceBase.Run(ServicesToRun);
        }
        else
        {
            // Run as a Windows console application
            DemoIpcServer m_server = new DemoIpcServer();
            m_server.Start();

            // Since all the requests are issued asynchronously, the constructors are likely to return
            // before all the requests are complete. The call below stops the application from terminating
            // until we see all the responses displayed.
            Thread.Sleep(1000);
            Console.WriteLine("\nPress return to shutdown server");
            Console.ReadLine();

            m_server.Stop();

            Console.WriteLine("\nComplete! Press return to exit program");
            Console.ReadLine();
        }
    }
Exemple #3
0
 protected override void OnStop()
 {
     m_server.Stop();
 }