Oded
Oded

Reputation: 795

Can a WCF service call a method not from the client?

I've created a WCF service application containing a client, contract and a service. I use the client to call methods implemented in the service.

Is there a way to have a timer in the service and to set its interval to tick and to have a method that is executing during the time the service is being called.

I tried to create a constructor to the service (static and non-static) but it didn't work.

I thought about creating a 3rd party client, which will execute a method implemented in the service which will do what I need.

Thanks, Oded.

Upvotes: 0

Views: 520

Answers (1)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65471

If you want something running while the service is called, then you could do it from the client:

  • Call start process from the client
  • Call the service from the client
  • Call stop process from the client

You could also do it on the server side:

  • Your first line in the service is start process
  • Your last line in the service is stop process

Note you must be carefull about error handling, otherwise you will end up with many orphaned processes.

Upvotes: 1

Related Questions