the ServiceCustomCommand interface

48 views
Skip to first unread message

Escher4096

unread,
Apr 17, 2014, 6:11:41 PM4/17/14
to topshelf...@googlegroups.com
Hi there,

There is an interface called 'ServiceCustomCommand' that looks like it is intended to allow a service to receive/handle custom commands. I have added this interface to my implementation class but when I attach my debugger to the service it never gets called. I was just wondering if there was some additional setup/configuration that needed to be done?

class Program
    {
        static void Main(string[] args)
        {

            HostFactory.Run(hostConfigurator =>
            {
                hostConfigurator.Service<WServ>(serviceConfigurator =>
                {
                    serviceConfigurator.ConstructUsing(() => new WServ());
                    serviceConfigurator.WhenStarted(myService => myService.Start());
                    serviceConfigurator.WhenStopped(myService => myService.Stop());
                    
                });

                hostConfigurator.RunAsLocalSystem();

                hostConfigurator.SetDisplayName("CAM_WServ");
                hostConfigurator.SetDescription("WServ using Topshelf");
                hostConfigurator.SetServiceName("CamWserv");
            });

        }
    }

 

    public class WServ : ServiceCustomCommand
    {
        // --------------- 8< ------ snip ---------- >8 ------------------------\\

        public void CustomCommand(HostControl hostControl, int command)
        {
            Console.WriteLine("Custom Command - " + command.ToString());
        }
    }

Thanks

-Cam

Chris Patterson

unread,
Apr 17, 2014, 7:10:16 PM4/17/14
to topshelf...@googlegroups.com
Pretty sure you need to implement ServiceControl as well, instead of using the delegates for Start/Stop.


--
You received this message because you are subscribed to the Google Groups "topshelf-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topshelf-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages