7

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 that 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.

missimer
  • 4,022
  • 1
  • 19
  • 33
Ender
  • 931
  • 2
  • 8
  • 16
  • Yes, I have experienced CTRL+ALT+DELETE thawing a frozen system. – David Heffernan Aug 30 '11 at 20:39
  • Favorite-ed : Oah... I'm working right now on this kind of WPF app, and the last thing I want is to freeze the OS. I'm interested in whatever data can be had on this (i.e. potential sources/solutions to this problem) – paercebal Aug 30 '11 at 20:42
  • @David: What was the root issue of the system freeze in your case ? – Ender Aug 30 '11 at 20:49
  • Your question only asks if anyone else has experienced it. Doesn't ask why it happens! I tend to notice it when I am debugging, so not really an issue for production code. – David Heffernan Aug 30 '11 at 20:52
  • Sorry, I thought it was explicit I am looking for the cause. I am experiencing this issue in production as well. – Ender Aug 30 '11 at 21:00

4 Answers4

4

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.

Community
  • 1
  • 1
Adnan Bhatti
  • 3,410
  • 4
  • 25
  • 38
3

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.

Ender
  • 931
  • 2
  • 8
  • 16
  • For anyone else facing this problem, your deadlock could be anywhere. What you need to do is Break All in Visual Studio, and then look through the Threads Window and check each thread's stack to find which threads are stuck and why. See more detailed information here: https://stackoverflow.com/questions/1147387/how-to-debug-a-deadlock – Rick Velde Jan 08 '19 at 20:06
1

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.

Skrymsli
  • 5,173
  • 7
  • 34
  • 36
0

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.

Carlos Quintanilla
  • 12,937
  • 3
  • 22
  • 25