private uint Send(byte[] data) { uint bytesWritten = 0; try { mailslot.Handle = WinFunctions.CreateFile(target, WinFunctions.FileDesiredAccess.GenericWrite, 0, IntPtr.Zero, WinFunctions.FileCreationDisposition.OpenExisting, 0, IntPtr.Zero); WinFunctions.WriteFile(mailslot.Handle, data, (uint)data.Length, out bytesWritten, IntPtr.Zero); } catch (Exception ex) { WinFunctions.ThrowException("Send failed.", ex); } finally { if (mailslot.IsValid()) { mailslot.Dispose(); } } return(bytesWritten); }
public void Dispose() { receiverThread.Abort(); mailslot.Dispose(); GC.SuppressFinalize(this); }