//************************************************** // Iterates through message queues and displays the // path of each queue that was created in the last // day and that exists on the computer "MyComputer". //************************************************** public void ListPublicQueuesByCriteria() { uint numberQueues = 0; // Specify the criteria to filter by. MessageQueueCriteria myCriteria = new MessageQueueCriteria(); myCriteria.MachineName = "MyComputer"; myCriteria.CreatedAfter = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0)); // Get a cursor into the queues on the network. MessageQueueEnumerator myQueueEnumerator = MessageQueue.GetMessageQueueEnumerator(myCriteria); // Move to the next queue and read its path. while (myQueueEnumerator.MoveNext()) { // Increase the count if priority is Lowest. Console.WriteLine(myQueueEnumerator.Current.Path); numberQueues++; } // Handle no queues matching the criteria. if (numberQueues == 0) { Console.WriteLine("No public queues match criteria."); } return; }
//************************************************** // Iterates through message queues and examines the // path for each queue. Also displays the number of // public queues on the network. //************************************************** public void ListPublicQueues() { // Holds the count of private queues. uint numberQueues = 0; // Get a cursor into the queues on the network. MessageQueueEnumerator myQueueEnumerator = MessageQueue.GetMessageQueueEnumerator(); // Move to the next queue and read its path. while (myQueueEnumerator.MoveNext()) { // Increase the count if priority is Lowest. Console.WriteLine(myQueueEnumerator.Current.Path); numberQueues++; } // Display final count. Console.WriteLine("Number of public queues: " + numberQueues.ToString()); return; }