Hello,
I need to start async tasks after AppHost is initialised.
For now my code is:
public override void Configure(Container container)
{
...
var printerStatusChecker = new PrinterStatusChecker(dbFactory);
container.Register(printerStatusChecker);
var itlcTcpClient = new ItlcTcpClient(dbFactory);
container.Register(itlcTcpClient);
AfterInitCallbacks.Add(async host =>
{
var printerStatusTask = printerStatusChecker.StartAsync();
var itlcTcpClientTask = itlcTcpClient.StartAsync();
await Task.WhenAll(printerStatusTask, itlcTcpClientTask);
});
}
Both PrinterStatusChecker
and ItlcTcpClient
have while(true) { .. }
loops inside StartAsync methods and will never finish executing non blocking code inside loop.
Everything seems to working fine, but do you see any problems or maybe better way to start these tasks?
Thank you,
Dejan