我想在调用 WCFService() 构造函数后调用方法“ StartListen() ”,我可以在第一次客户端调用后调用此方法“StartListen()”,但不管客户端调用如何,我想在服务之后执行此操作类是构造的,有可能吗?或者是否有任何其他机制可以满足这种需求?
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class WCFService : IWCFService
{
public WCFService()
{
// do initializing here
}
// implementation of the operation contract
public void NotifyToService()
{
// method will be called by the client
}
//this internal method has to be called after the class is constructed
public void StartListen()
{
// some listening action
}
}