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