Interfacing a Window Service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wolfenstein
    New Member
    • Mar 2008
    • 25

    Interfacing a Window Service

    Hi,

    I'm working on a window service and i want to give an interface to it. What can be the best approach to get this done.

    Can i include a Form, when the user starts the service then gives some parameters only on the start. then the service is started and continue its work.

    No need to give values on run-time.
    Looking for best approaches..... ............... .
  • balame2004
    New Member
    • Mar 2008
    • 142

    #2
    Originally posted by wolfenstein
    Hi,

    I'm working on a window service and i want to give an interface to it. What can be the best approach to get this done.

    Can i include a Form, when the user starts the service then gives some parameters only on the start. then the service is started and continue its work.

    No need to give values on run-time.
    Looking for best approaches..... ............... .

    Hi,


    There are two different approaches to show an interface while windows service service is running.

    1. Create a dll with a public method which invokes show method of a windows form and call the public method from OnStart event of windows service(Also add reference to the dll) .
    2.Create a windows application and start it while windows service is being started and stop it while windows service is stopped.

    Here is the sample code for the second option.

    //Global variable
    private System.Diagnost ics.Process process;

    ---
    ---
    ---

    protected override void OnStart(string[] args)
    {
    process = System.Diagnost ics.Process.Sta rt("WindowsAppl ication2.exe");
    }
    protected override void OnStop()
    {
    process.Kill();
    }


    Regards,
    Balaji U

    Comment

    Working...