public byte[] GetNextMessage() { var size = GetNextMessageSize(); if (size == null) { return(null); } return(RawMailSlot.ReadBytes(_handle, size.Value)); }
private MailSlot(string name, bool server) { try { if (server) { _handle = RawMailSlot.CreateMailSlot(name); } else { _handle = RawMailSlot.CreateFile(name); } } catch (Exception ex) { throw new Exception($"Unable to create new mailslot with path {name}", ex); } if (_handle.IsInvalid) { throw new Exception($"Unable to create new mailslot with path {name}", new Win32Exception()); } }
public void SendMessage(byte[] msg) { RawMailSlot.WriteBytes(_handle, msg); }
private int?GetNextMessageSize() { return(RawMailSlot.GetInfo(_handle)); }