我在我的 WPF 应用程序中使用串行端口,并且日志文件中有许多错误,例如“没有足够的配额来处理此命令”。
这个来源我认为有问题。我的错误在哪里?
void barcodeSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string code = barcodeSerialPort.ReadLine();
this.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate()
{
if (new DateTime(model.ComebackDate.Year, model.ComebackDate.Month, model.ComebackDate.Day) > DateTime.Now)
{
new WndMessage("Date time error...").ShowDialog();
Switcher.Switch(new MainMenu());
return;
}
// ...............
});
10.01.2013 10:05:08 - Exception on UI Thread (Dispatcher)
Exception message - There is not enough quota to process this command
Source - WindowsBase
StackTrace - at MS.Win32.UnsafeNativeMethods.PostMessage(HandleRef hwnd, WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
TargetSite -Void PostMessage(System.Runtime.InteropServices.HandleRef, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr)
InnerException.Message - NULL