public async Task StopAsync() { if (!IsStarted) { return; } Log.Information("Stopping service..."); await DoWork(async() => { m_Automation.Stop(); IsStarted = false; await m_Automation.CloseDevicesAsync(); }); Log.Information("Service has stopped"); }