开发者

WPF application freezes Windows 7

开发者 https://www.devze.com 2023-03-31 16:40 出处:网络
I have a .NET 3.5 WPF application on Windows 7 64bit. I am experiencing odd system freeze issue that happens when dragging and moving the main application window. Basically the entire system freezes (

I have a .NET 3.5 WPF application on Windows 7 64bit. I am experiencing odd system freeze issue that happens when dragging and moving the main application window. Basically the entire system freezes (UI) and the application stops rendering. Bringing up the task manager (CTRL+ALT+DEL) unfreezes both system and the application.

The application itself is a trading application tha开发者_StackOverflow中文版t processes a large amount of messages in background threads.

Has anyone experienced this type of issues ? Especially the oddity of task manager unlocking the freeze. What could be the reason for this strange behavior?

I am almost certain it has something to do with dispatching certain actions to the UI thread.


Found some old post on StackOverflow that may help, It is said it may be due to font cache.

"I had the same problem. It was a corrupt font cache!!

See http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7cc032c1-5f4d-4518-adc6-f53afd051e6b for a solution.

"

WPF Application Hang

Here are the steps that were asked to take.

In Win 7

1. Run services.msc
2. Stop Windows Presentation Foundation Font Cache 3.0.0.0 service
3. Delete FontCache3.0.0.0.dat 

 in XP: 
%systemdrive%\Documents and Settings\LocalService\Local Settings\Application Data 

in Vista: %windir%\ServiceProfiles\LocalService\AppData\Local

4. Restart the machine

What I do know is you can do the following.

The Windows operating system has a font cache file that is located here: C:\Windows\System32\FNTCACHE.DAT

Delete this file, and restart your system.


The issue was WCF service deadlocking. Issue similar to this

In the service that processed messages incoming messages had to be added on the UI thread to the collection the following way.

Action action = new Action(() =>
            {
                lock (_messagesLock)
                {
                    _messages.Remove(message);
                }
            });
            _dispatcher.Invoke(DispatcherPriority.Normal, action);

Changing

_dispatcher.Invoke(DispatcherPriority.Normal, action);

To

_dispatcher.BeginInvoke(DispatcherPriority.Normal, action);

Solved the issue.


Since WPF uses DirectX you should also make sure that DirectX and your video drivers are up to date and working correctly. A faulty video card or video driver could cause problems for WPF that might not manifest in other Win32 apps.


If you are using VS2010 and running the WPF app in Win 7 64 bit the answer to your issue may be this one:

Improving Performance by Changing the Visual Experience

You might have a problem with Hardware Acceleration in VS2010. I had an issue with rendering applications built using WPF because of this.

Give it a try: http://blogs.msdn.com/b/zainnab/archive/2010/06/22/improving-performance-by-changing-the-visual-experience-vstipenv0017.aspx

And if that doesn't fix your issue, go to your video card settings (nvidia or amd) and do a "reset settings". Then try again.

0

精彩评论

暂无评论...
验证码 换一张
取 消