public SharedMemoryRecordingHeader ReadHeader()
        {
            var header = new SharedMemoryRecordingHeader();

            using (var reader = new BinaryReader(input: _fileStream, encoding: Encoding.UTF8, leaveOpen: true))
            {
                header.Magic          = reader.ReadBytes(4);
                header.NumSamples     = reader.ReadUInt64();
                header.SampleInterval = reader.ReadUInt16();
            }
            return(header);
        }
 public void WriteHeader()
 {
     _fileStream.Seek(0, SeekOrigin.Begin);
     using (var writer = new BinaryWriter(output: _fileStream, encoding: Encoding.UTF8, leaveOpen: true))
     {
         var header = new SharedMemoryRecordingHeader();
         header.Magic = new byte[4] {
             (byte)'S', (byte)'M', (byte)'X', (byte)'2'
         };
         header.NumSamples     = NumSamples;
         header.SampleInterval = DEFAULT_SAMPLING_INTERVAL_MS;
         writer.Write(header.Magic, 0, header.Magic.Length);
         writer.Write(header.NumSamples);
         writer.Write(header.SampleInterval);
         writer.Flush();
     }
 }