예제 #1
0
        public byte[] GetNextMessage()
        {
            var size = GetNextMessageSize();

            if (size == null)
            {
                return(null);
            }
            return(RawMailSlot.ReadBytes(_handle, size.Value));
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
 public void SendMessage(byte[] msg)
 {
     RawMailSlot.WriteBytes(_handle, msg);
 }
예제 #4
0
 private int?GetNextMessageSize()
 {
     return(RawMailSlot.GetInfo(_handle));
 }