public static StorageFile FinishRecording(RecordingScope recording, StorageFileFormat format, Action <float> progress) { if (recording.Busy) { throw new Exception("Recording is still ongoing. Stop the recording before storing it"); } string filename = null; switch (format) { case StorageFileFormat.MATLAB: filename = StoreMatlab(recording, progress); break; case StorageFileFormat.CSV: filename = StoreCsv(recording, progress); break; default: break; } //and clean up recording.Dispose(); return(new StorageFile() { info = new FileInfo(filename), format = format }); }
public static void FinishRecordingAsync(RecordingScope r, StorageFileFormat format, Action <float> progress, Action <StorageFile> success, Action <Exception> failure) { //Check if recording is done (i.e. no data is gonna be added and we can store it safely) Thread frt = new Thread(FinishRecording); frt.Start(new object[] { r, format, progress, success, failure }); }
public static string GetFileExtension(this StorageFileFormat f) { switch (f) { case StorageFileFormat.MATLAB: return(".mat"); case StorageFileFormat.CSV: return(".csv"); } throw new Exception("Unknown file format"); }
private static void FinishRecording(object arg) { object[] args = arg as object[]; RecordingScope recording = (RecordingScope)args[0]; StorageFileFormat format = (StorageFileFormat)args[1]; Action <float> progress = args[2] as Action <float>; Action <StorageFile> success = args[3] as Action <StorageFile>; Action <Exception> failure = args[4] as Action <Exception>; success(FinishRecording(recording, format, progress)); }