public async Task <(bool, string)> StopProcedure() { if (!File.Exists(FileName)) { string msg = $"File {FileName} does not exist"; Logger?.LogWarning(msg); return(false, msg); } if (FileClosed) { return(GeneralUtils.CheckFileSize(FileName)); } FileClosed = true; Logger?.LogInformation("Stop Procedure called"); ProcedureInformation.EndDateTime = DateTime.Now; if (RecordingInProgress) { StopRecording(); } await CloseHandles(); Hdf5.Flush(groupRoot, H5F.scope_t.GLOBAL); Hdf5.CloseGroup(groupEIT); Hdf5.CloseGroup(groupRoot); long result = Hdf5.CloseFile(fileId); if (result >= 0) { Logger?.LogInformation("Stop Procedure H5 File closed"); } else { Logger?.LogError("Cannot close H5 File: " + result); } return(GeneralUtils.CheckFileSize(FileName)); }