MessageQueue.InfiniteTimeout 欄位

定義

指定窺視 (Peek) 或接收訊息的方法沒有逾時限制。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 

欄位值

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. 同步方法 PeekReceive ,會使進程執行緒等待指定的時間間隔,讓新訊息抵達佇列。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.

適用於

另請參閱