protected override async Task StartInternal() { using (_dlock = await _lockService.CreateLockAsync(this.ProcessName, TimeSpan.FromSeconds(1), TimeSpan.MaxValue, TimeSpan.FromSeconds(1), StopRequested.Token, () => { // if process was not stopped from outside, restart it so it can try to acquire lock again if (!StopRequested.IsCancellationRequested) { try { Stop().Wait(); } catch (Exception e) { //todo : log } Start(); } })) { if (_dlock != null && _dlock.IsAcquired) { await _innerProcess.Start(); //await Stop(); return; } } await StartInternal(); }