vinay singri
vinay singri

Reputation: 199

WCF service hosted in Windows service

I have a WCF service hosted in a Windows service. When user modifies the WCF service configuration,he needs to restart the service.

I wanted to know if restarting the windows service is better by using

serviceController.stop() 
servicecontroller.start()

or by creating a new instance of the WCF client every time he wants to restart it. No information will be lost if created a new instance of the WCF client.

Upvotes: 1

Views: 260

Answers (1)

Surjit Samra
Surjit Samra

Reputation: 4662

In your service container which is inherited from System.ServiceProcess.ServiceBase

you should start your service inside method

protected override void OnStart(string[] args)
{
  servicecontroller.start()
}

and stop your services inside method

protected override void OnStop()
{
    //here clean up code or any tear-down necessary to stop your service.
  serviceController.stop() 
 }

so these methods are called automatically when you start/stop windows service from services pallet.

As others said there is no effect of creating a new instance of the WCF client every time on your service

Upvotes: 2

Related Questions