我有 Windows 应用程序。应用程序从 MS 消息队列中读取消息。应用程序中的问题是有时不要从消息队列中读取消息并抛出此异常。
Thread was being aborted.
at System.Messaging.Interop.UnsafeNativeMethods.MQReceiveMessage(MessageQueueHandle handle, UInt32 timeout, Int32 action, MQPROPS properties, NativeOverlapped* overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, IntPtr transaction)
at System.Messaging.MessageQueue.StaleSafeReceiveMessage(UInt32 timeout, Int32 action, MQPROPS properties, NativeOverlapped* overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, IntPtr transaction)
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Receive()
at Catalyst.CATS.DBService.OrdersQueueHandler.SynReceiveThreadMethod() in D:\svn\kinetic\Servers\Main DB Service\trunk\MainDatabaseServiceGUI\DBMainLogic\classes\OrdersQueueHandler.cs:line 143
我无法弄清楚问题请帮助我
我的应用程序下面有简短的代码示例。
public class Messages
{
private MessageQueue OrdersQueue;
OrdersQueue = MessageQueue.Create(".\\Private$\\DatabaseServerQueue", false);
OrdersQueue.SetPermissions("Everyone", System.Messaging.MessageQueueAccessRights.FullControl);
OrdersQueue.SetPermissions("ANONYMOUS LOGON", System.Messaging.MessageQueueAccessRights.FullControl);
OrdersQueue.UseJournalQueue = true;
public Messages()
{
thd = new Thread(new ThreadStart(SynReceiveThreadMethod));
thd.Start();
}
private void SynReceiveThreadMethod()
{
while(true)
{
try
{
Message dequeuedMessage = OrdersQueue.Receive();
}
catch (Exception ee)
{
System.Console.WriteLine(ee.Message);
System.Console.WriteLine(ee.StackTrace);
}
}
}
}