I'm developing a service, which is to run 24/7 and is to be controlled over MVC web-site, but it's not that important. What does matter though, is that What I have now is (for windows service):
protected override void OnStart(string[] args)
{
if (this.ServiceHost != null)
this.ServiceHost.Close();
this.ServiceHost = new ServiceHost(typeof(ParserService));
this.ServiceHost.Open();
}
And ParserService is as the following at the moment:
public class ParserService : IParserService
{
private ParserFacade FacadeForParser;
public void Start()
{
if(FacadeForParser == null)
this.FacadeForParser = new ParserFacade();
this.FacadeForParser.Start();
}
public bool IsRunning()
{
return true;
}
public void Stop()
{
this.FacadeForParser.Stop();
}
public List<string> GetAllTitles()
{
return this.FacadeForParser.GetAllTitles();
}
}
And the problem is: In Parser service, FacadeForParser is never seaved for the next call. Seems like I misunderstood lifecycle of WCF classes... So Can anyone tell me correct way to implement this part?
I do need: 1 instance of ParserFacade to work with it through all the requests ever handled by WCF part of the service.