MessageQueue.CanRead Property


Gets a value that indicates whether the MessageQueue can be read.

 property bool CanRead { bool get(); };
public bool CanRead { get; }
member this.CanRead : bool
Public ReadOnly Property CanRead As Boolean

Property Value


true if the MessageQueue exists and the application can read from it; otherwise, false.



The following code example displays the value of a message queue's CanRead property.

// Display the value of the queue's CanRead property.
Console.WriteLine("MessageQueue.CanRead: {0}", queue.CanRead);


CanRead indicates whether the application is able to peek or receive messages from the queue. If CanRead is true, the MessageQueue can receive or peek messages from the queue. Otherwise, it cannot.

CanRead is false if a queue is already open with exclusive read access (or if it's open with non-exclusive access and this MessageQueue requests exclusive access), or if the application does not have sufficient rights to access it. If your application tries to read from a queue when CanRead is false, access is denied.

The following table shows whether this property is available in various Workgroup modes.

Workgroup mode Available
Local computer Yes
Local computer and direct format name Yes
Remote computer No
Remote computer and direct format name Yes

Applies to

See also