MessageQueue.InfiniteTimeout 字段
定义
指定对查看或接收消息的方法不存在超时设定。Specifies that no time-out exists for methods that peek or receive messages.
public: static initonly TimeSpan InfiniteTimeout;
public static readonly TimeSpan InfiniteTimeout;
staticval mutable InfiniteTimeout : TimeSpan
Public Shared ReadOnly InfiniteTimeout As TimeSpan
字段值
示例
下面的代码示例演示如何使用 InfiniteTimeout 成员。The following code example demonstrates the use of the InfiniteTimeout member.
// Create a new message.
Message msg = new Message();
// Set the message's TimeToReachQueue property to
// MessageQueue.InfiniteTimeout.
msg.TimeToReachQueue = MessageQueue.InfiniteTimeout;
// Display the new value of the message's TimeToReachQueue property.
Console.WriteLine("Message.TimeToReachQueue: {0}",
msg.TimeToReachQueue.ToString());
注解
MessageQueue 支持两种类型的消息检索:同步和异步。MessageQueue supports two types of message retrieval: synchronous and asynchronous. 同步方法和将 Peek Receive 导致进程线程等待指定的时间间隔,以使新消息到达队列。The synchronous methods, Peek and Receive, cause the process thread to wait a specified time interval for a new message to arrive in the queue. 如果指定的时间间隔为 InfiniteTimeout ,则进程线程将保持阻止状态,直到新消息可用。If the specified time interval is InfiniteTimeout, the process thread remains blocked until a new message is available. 另一方面,如果 BeginPeek BeginReceive 异步方法) (,则允许主应用程序任务在单独的线程中继续,直到消息到达队列。On the other hand, BeginPeek and BeginReceive (the asynchronous methods), allow the main application tasks to continue in a separate thread until a message arrives in the queue.