private async void Stop_Click(object sender, RoutedEventArgs e) { //Send the stop command and save sample data to a csv file Stop.IsEnabled = false; Status.Text = (await Oven.Stop()).ToString(); try { var filename = $"{DateTime.Now:yyyy-MM-dd HHmmss}.csv"; var file = await DownloadsFolder.CreateFileAsync(filename); var lines = new List <string> { "RealTime,RecipeTime (s),Temperature (°C),Ambient Temp (°C),Set Power (W)" }; foreach (var sample in SampleData) { lines.Add($"{sample.RealTime:yyyy-MM-dd HH:mm:ss},{sample.Time},{sample.Temperature},{sample.Ambient},{sample.Power}"); } await FileIO.WriteLinesAsync(file, lines); await CachedFileManager.CompleteUpdatesAsync(file); } catch (Exception x) { await ShowError($"Error saving data file:{Environment.NewLine}{x.Message}"); } Stop.IsEnabled = true; }