Winforms onPaint着火次数太多

Winforms onPaint着火次数太多,winforms,wcf,winforms-interop,Winforms,Wcf,Winforms Interop,我有一个winforms用户控件,允许用户在面板上编辑工作流。工作流由构建块和连接组成,它们也是我的用户控件 当我将应用程序从winforms.exe迁移到另一个WCF应用程序上的winform控件时,我注意到CPU使用率上升到25%(=我的4核机器单核的100%) 一旦出现以下情况,CPU将在运行时下降到0-1%: 从任何现有控件中清除工作流面板,或 我将屏幕焦点移动到另一个应用程序(并让它在后台运行),甚至是同一应用程序中的不同选项卡 必须指出的是,这种情况不会发生在Windows窗体宿主应

我有一个winforms用户控件,允许用户在面板上编辑工作流。工作流由构建块和连接组成,它们也是我的用户控件

当我将应用程序从winforms.exe迁移到另一个WCF应用程序上的winform控件时,我注意到CPU使用率上升到25%(=我的4核机器单核的100%)

一旦出现以下情况,CPU将在运行时下降到0-1%:

从任何现有控件中清除工作流面板,或

我将屏幕焦点移动到另一个应用程序(并让它在后台运行),甚至是同一应用程序中的不同选项卡

必须指出的是,这种情况不会发生在Windows窗体宿主应用程序中,而只发生在WCF中

我看到了一个地方,他们覆盖了基本工作流块UC的WndProc方法,我也这样做了,但我仍然不明白是什么在多次调用WndProc方法,或者如何停止它

我的堆栈看起来像:

BaseControls.dll!Ast.Admin.Controls.BaseControl.WndProc(ref System.Windows.Forms.Message m={System.Windows.Forms.Message})第91行C# System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(参考System.Windows.Forms.Message m)+0x1d字节
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(参考System.Windows.Forms.Message m)+0xaa字节
System.Windows.Forms.dll!回调(System.IntPtr hWnd,int msg=129,System.IntPtr wparam,System.IntPtr lparam)+0x6f字节 System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.WindowClass.Callback(System.IntPtr hWnd、int msg、System.IntPtr wparam、System.IntPtr lparam)+0x51字节
[本机到托管转换]
[管理到本机转换]
System.Windows.Forms.dll!System.Windows.Forms.UnsafentiveMethods.CreateWindowEx(int-dwExStyle,string-lpszClassName,string-lpszWindowName,int-style,int-x,int-y,int-width,int-height,System.Runtime.InteropServices.HandleRef-hWndParent,System.Runtime.InteropServices.HandleRef-Humenu,System.Runtime.InteropServices.HandleRef-hInst,object-pvParam)+0x3f字节
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp)+0x22d字节 System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle()+0x12c字节
System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl(bool-fIgnoreVisible=false)+0x89字节
System.Windows.Forms.dll!System.Windows.Forms.Control.CreateControl()+0x31字节
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlCollection.Add(System.Windows.Forms.Control值={Ast.Controls.AllianceEnterprise.DataSource})+0x1dd字节
AdminUC.dll!Ast.Admin.AdminUC.RuleBuilderUC.AddItem(object objData=“C:\Ast Alliance NextUI\Bin\Escalation\Controls\Actions\DataConnector.dll;Ast.Controls.AllianceEnterprise.DataSource”)+0x510字节 AdminUC.dll!Ast.Admin.AdminUC.RuleBuilderUC.drawingPanel_DragDrop(对象发送方={System.Windows.Forms.Panel},System.Windows.Forms.DragEventArgs e={System.Windows.Forms.DragEventArgs})+0xa0字节
System.Windows.Forms.dll!System.Windows.Forms.Control.OnDragDrop(System.Windows.Forms.DragEventArgs drgevent)+0x73字节
System.Windows.Forms.dll!System.Windows.Forms.Control.System.Windows.Forms.IDropTarget.OnDragDrop(System.Windows.Forms.DragEventArgs drgEvent)+0x15字节 System.Windows.Forms.dll!System.Windows.Forms.DropTarget.System.Windows.Forms.UnsafentiveMethods.IOleDropTarget.OleDrop(对象pDataObj,int-grfKeyState,long pt,ref-int-pdwefect=1)+0x5d字节 [本机到托管转换]
[管理到本机转换]
System.Windows.Forms.dll!System.Windows.Forms.Control.DoDragDrop(对象数据,System.Windows.Forms.DragDropEffects allowedEffects)+0xed字节 AdminUC.dll!Ast.Admin.AdminUC.RuleBuilderUC.listView_MouseDown(对象发送方={System.Windows.Forms.listView},System.Windows.Forms.MouseEventArgs e={X=16 Y=6 Button=Left})+0x285字节 System.Windows.Forms.dll!System.Windows.Forms.Control.OnMouseDown(System.Windows.Forms.MouseEventArgs e)+0x73字节
System.Windows.Forms.dll!System.Windows.Forms.ListView.WmMouseDown(参考System.Windows.Forms.Message m={System.Windows.Forms.Message},System.Windows.Forms.MouseButtons按钮,整数点击)+0x7a字节
System.Windows.Forms.dll!System.Windows.Forms.ListView.WndProc(ref System.Windows.Forms.Message m)+0xf7字节 System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(参考System.Windows.Forms.Message m)+0x1d字节
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(参考System.Windows.Forms.Message m)+0xaa字节
System.Windows.Forms.dll!回调(System.IntPtr hWnd,int msg=513,System.IntPtr wparam,System.IntPtr lparam)+0x6f字节 [本机到托管转换]
[管理到本机转换]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame={System.Windows.Threading.DispatcherFrame})+0xb5字节 WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame框架)+0x3c字节
PresentationFramework.dll!System.Windows.Application.RunDispatcher(对象忽略)+0x34字节
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window窗口)+0x16f字节
PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window窗口)+0x33字节 PresentationFramework.dll!System.Windows.Application.Run()+0x69字节 Ast Browser.exe!Ast.NextUI.GUI.Shell.App.StartApplication()+0x75字节
阿斯特兄弟
[Managed to Native Transition]
 System.Windows.Forms.dll!System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(int dwExStyle, string lpszClassName, string lpszWindowName, int style, int x, int y, int width, int height, System.Runtime.InteropServices.HandleRef hWndParent, System.Runtime.InteropServices.HandleRef hMenu, System.Runtime.InteropServices.HandleRef hInst, object pvParam) + 0x3f bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp) + 0x22d bytes 
System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle() + 0x12c bytes