public void StartReader()
 {
     if (this.IntercomStatus != IpcMMFinterComSF.MMFinterComTStatus._Null || ReadPosition < 0 || writePosition < 0)
     {
         return;
     }
     this.IntercomStatus = IpcMMFinterComSF.MMFinterComTStatus.PreparingReader;
     System.Threading.Thread t = new System.Threading.Thread(ReaderThread);
     t.IsBackground = true;
     t.Start();
 }
 private void ReaderThread(object stateInfo)
 {
     // Checks if there is something to read.
     this.IntercomStatus = IpcMMFinterComSF.MMFinterComTStatus.TryingToRead;
     this.reading        = accessor.ReadBoolean(ReadPosition + DATA_AVAILABLE_OFFSET);
     if (this.reading)
     {
         this.IntercomStatus = IpcMMFinterComSF.MMFinterComTStatus.ReadingData;
         // Checks how many bytes to read.
         int availableBytes = accessor.ReadInt32(ReadPosition + DATA_LENGTH_OFFSET);
         this.ReadData = new byte[availableBytes];
         // Reads the byte array.
         int read = accessor.ReadArray <byte>(ReadPosition + DATA_OFFSET, this.ReadData, 0, availableBytes);
         // Sets the flag used to signal that there aren't available data anymore.
         accessor.Write(ReadPosition + DATA_AVAILABLE_OFFSET, false);
         // Sets the flag used to signal that data has been read.
         accessor.Write(ReadPosition + READ_CONFIRM_OFFSET, true);
         this.IntercomStatus = IpcMMFinterComSF.MMFinterComTStatus.FinishedReading;
     }
     else
     {
         this.IntercomStatus = IpcMMFinterComSF.MMFinterComTStatus._Null;
     }
 }