Could anyone explain to me why my server stopped for no reason? below my IHostedService implementation:
public class HostServiceBox : IHostedService
{
public Task StartAsync(CancellationToken cancellationToken)
{
return Task.Run(() =>
{
DomonutyBoxBusiness.StartBoxListening(); //STARTUP Box listening
while (true)
{
Logging.Info(DateTime.Now + " HostServiceBox Running");
Thread.Sleep(10000);
}
}, cancellationToken);
}
public Task StopAsync(CancellationToken cancellationToken)
{
Logging.Info(DateTime.Now + " StopAsync");
// TODO implement a stop listening all boxes
throw new NotImplementedException();
}
}
Here is my log?
.....
2/24/2018 8:31:27 PM HostServiceBox Running
2/24/2018 8:32:27 PM HostServiceBox Running
2/24/2018 8:33:27 PM HostServiceBox Running
2/24/2018 8:34:27 PM HostServiceBox Running <------
2/25/2018 11:22:07 AM HostServiceBox Running <-----
2/25/2018 11:23:07 AM HostServiceBox Running
2/25/2018 11:24:07 AM HostServiceBox Running
2/25/2018 11:25:07 AM HostServiceBox Running
......
is look like on IIS with kestrel (.Net Core) my method slept ? Why?
Usualy my while(true) restart because i call the API. But IHostedService is a background task it's shouldnt stop right?
related post on github
Event Viewer
? – Lu