Reputation: 6289
This Thread belong to this
I am asking where do I need to insert the workaround from this
I have a WPF application which has performance issue on some clients with Windows 7. On Windows XP all is working fast. The application has a MainShell and some Child-Windows. The MainShell hangs sometimes on some machines, and so do the child windows. Now, do I have to insert the workaround from the thread from the above link in all windows? Are there still other workaround about this?
Upvotes: 4
Views: 6700
Reputation: 16986
I have been working on an application that has been fine on virtually everything but the WPF Controls were slow on certain laptops (Lenovo). It was lagging and freezing and generally inhibiting use.
I did the following:
It may be that only Number 3 was required, but it worked. Just posting here so people dont lose the days I lost in memory profilers etc.
Upvotes: 3
Reputation: 9552
In my case it worked by adding that code to the main window. However, I simplified it a bit:
public partial class MyMainWindow : Window
{
public MyMainWindow() {
GotFocus += WindowGotFocus;
}
private void WindowGotFocus(object sender, RoutedEventArgs e)
{
WindowInteropHelper helper = new WindowInteropHelper(this);
var mainWindowAutomationElement = AutomationElement.FromHandle(helper.Handle);
Automation.AddStructureChangedEventHandler(mainWindowAutomationElement, TreeScope.Element,
delegate {});
GotFocus -= WindowGotFocus;
}
}
The only problem with this approach, in my machine, is that the debugger window gets cluttered with messages like:
All happening many many times. I couldn't fix these messages, but my application is running faster now.
Upvotes: 1