K
K Viltersten
I've developped a service as follows. I'd like to have it
that way PLUS be able to run it as a normal application
(see the commentin Main). Any pointers/suggestions on
how to get there smoothly?
class MyService : ServiceBase {
public static void Main() {
// Should i detect service/application and go:
// if(isService)
// ServiceBase.Run(new MyService());
// else
// doExecuteAnOtherMethod();
ServiceBase.Run(new MyService());
}
public MyService() {
this.ServiceName = "";
this.CanStop = true;
this.AutoLog = true;
}
protected override void OnStart(string[] args) {
base.OnStart(args);
_mySoftware = new MySoftware();
}
protected override void OnStop() {
base.OnStop();
_mySoftware = null;
}
private MySoftware _mySoftware;
}
that way PLUS be able to run it as a normal application
(see the commentin Main). Any pointers/suggestions on
how to get there smoothly?
class MyService : ServiceBase {
public static void Main() {
// Should i detect service/application and go:
// if(isService)
// ServiceBase.Run(new MyService());
// else
// doExecuteAnOtherMethod();
ServiceBase.Run(new MyService());
}
public MyService() {
this.ServiceName = "";
this.CanStop = true;
this.AutoLog = true;
}
protected override void OnStart(string[] args) {
base.OnStart(args);
_mySoftware = new MySoftware();
}
protected override void OnStop() {
base.OnStop();
_mySoftware = null;
}
private MySoftware _mySoftware;
}