コード例 #1
0
 /// <summary>
 /// Set the given mailslot's read timeout.
 /// </summary>
 /// <param name="readTimeout">Timeout for read operations in milliseconds. Set to uint.MaxValue for infinite timeout.</param>
 public static void SetMailslotTimeout(SafeMailslotHandle mailslotHandle, uint readTimeout)
 {
     if (!Imports.SetMailslotInfo(mailslotHandle, readTimeout))
     {
         throw Error.GetExceptionForLastError();
     }
 }
コード例 #2
0
ファイル: Mailslots.cs プロジェクト: carlossanlop/WInterop
        /// <summary>
        /// Get information for the given mailslot.
        /// </summary>
        public unsafe static MailslotInfo GetMailslotInfo(SafeMailslotHandle mailslotHandle)
        {
            MailslotInfo info = new MailslotInfo();

            Error.ThrowLastErrorIfFalse(
                Imports.GetMailslotInfo(
                    hMailslot: mailslotHandle,
                    lpMaxMessageSize: &info.MaxMessageSize,
                    lpNextSize: &info.NextSize,
                    lpMessageCount: &info.MessageCount,
                    lpReadTimeout: &info.ReadTimeout));

            return(info);
        }
コード例 #3
0
ファイル: Mailslots.cs プロジェクト: carlossanlop/WInterop
        /// <summary>
        /// Create a mailslot.
        /// </summary>
        /// <param name="name">Name of the mailslot.</param>
        /// <param name="maxMessageSize">Maximum size, in bytes, of messages that can be posted to the mailslot. 0 means any size.</param>
        /// <param name="readTimeout">
        /// Timeout, in milliseconds, that a read operation will wait for a message to be posted. 0 means do not wait, uint.MaxValue means
        /// wait indefinitely.
        /// </param>
        public unsafe static SafeMailslotHandle CreateMailslot(string name, uint maxMessageSize = 0, uint readTimeout = 0)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            SafeMailslotHandle handle = Imports.CreateMailslotW(name, maxMessageSize, readTimeout, null);

            if (handle.IsInvalid)
            {
                Error.ThrowLastError(name);
            }

            return(handle);
        }
コード例 #4
0
        /// <summary>
        /// Get information for the given mailslot.
        /// </summary>
        public static MailslotInfo GetMailslotInfo(SafeMailslotHandle mailslotHandle)
        {
            MailslotInfo info = new MailslotInfo();

            unsafe
            {
                if (!Imports.GetMailslotInfo(
                        hMailslot: mailslotHandle,
                        lpMaxMessageSize: &info.MaxMessageSize,
                        lpNextSize: &info.NextSize,
                        lpMessageCount: &info.MessageCount,
                        lpReadTimeout: &info.ReadTimeout))
                {
                    throw Error.GetExceptionForLastError();
                }
            }

            return(info);
        }
コード例 #5
0
ファイル: Mailslots.cs プロジェクト: carlossanlop/WInterop
 /// <summary>
 /// Set the given mailslot's read timeout.
 /// </summary>
 /// <param name="readTimeout">Timeout for read operations in milliseconds. Set to uint.MaxValue for infinite timeout.</param>
 public static void SetMailslotTimeout(SafeMailslotHandle mailslotHandle, uint readTimeout)
 => Error.ThrowLastErrorIfFalse(Imports.SetMailslotInfo(mailslotHandle, readTimeout));