public async Task MonoDisableAsync(bool force = false, CancellationToken cancellationToken = default) { var endTime = DateTime.UtcNow.Add(TimeSpan.FromSeconds(60)); bool monoRunState; while ((monoRunState = await GetMonoRunStateAsync(cancellationToken).ConfigureAwait(false)) || force && endTime > DateTime.UtcNow) { Logger.LogDebug("Sending Mono Disable Request (Forced? {forced})", force); await _meadowDevice.MonoDisableAsync(cancellationToken); Logger.LogDebug("Waiting for Meadow to cycle"); await Task.Delay(3000, cancellationToken) .ConfigureAwait(false); Logger.LogDebug("Re-initialize the device"); await ReInitializeMeadowAsync(cancellationToken).ConfigureAwait(false); force = false; } if (monoRunState) { throw new Exception("Failed to stop mono."); } }