I have implemented a sample windows service using TopShelf. But I have got a problem. When I start the service it stops... Could you take a look at my source code, please? ( I had putted the Thread.Sleep(Timeout.Infinite), but it seems not working )
public class Program
{
static void Main(string[] args)
{
LogManager.LogFactory = new NLogFactory();
ILog Log = LogManager.GetLogger(typeof(Program));
var appSettings = new AppSettings();
var host = HostFactory.New(x =>
{
x.Service<ServerAppHost>(s =>
{
s.SetServiceName("OfferUploader");
s.ConstructUsing(name => new ServerAppHost());
s.WhenStarted(tc =>
{
Log.Info("Starting service...");
tc.Init();
});
s.WhenStopped(tc =>
{
Log.Info("Stopping service...");
tc.Stop();
Log.Info("Done.");
});
});
x.RunAsLocalSystem();
x.SetDescription("OfferUploaderService");
x.SetDisplayName("OfferUploader");
x.SetServiceName("OfferUploader");
});
host.Run();
Thread.Sleep(Timeout.Infinite);