-1

我有一个 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(ref System.Windows.Forms.Message m) + 0x1d 字节
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0xaa 字节
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(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.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、对象 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(object sender = {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.UnsafeNativeMethods.IOleDropTarget.OleDrop(object pDataObj, int grfKeyState, long pt, ref int pdwEffect = 1) + 0x5d bytes [Native to Managed Transition]
[Managed to Native Transition]
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 按钮 = 左}) + 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 按钮,int 点击)+ 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.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 513, System.IntPtr wparam, System.IntPtr lparam) + 0x6f 字节 [本地到托管转换]
[托管到本地转换]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame = {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 字节
Ast Browser.exe!Ast.NextUI.GUI.Shell.App.Main(string[] args) + 0x22b 字节

其中 basecontrol 是我的工作流块的基类。

从我把第一块放在面板上的那一刻起,这种情况就一直在发生,而且我并没有在屏幕上做任何事情来证明所有这些痛苦。

4

1 回答 1

0

这是在做什么:

[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

看起来 OnPaint 正在被调用,因为这是第一次创建窗口。

如果这是一个典型的调用堆栈,在拖放应用程序期间每秒被调用数百次,那么您真的需要找出原因并停止它......

于 2012-08-23T13:53:49.643 回答