Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Mysterious Application Hang after Upgrade to Framework 2.0
posted

We recently upgraded our app from .NET Framework 1.1 to 2.0  The conversion from Infrag 7.1 CLR 1  to CLR 2 went very smoothly but the application would hang with unresponsive windows after a user returned from the Screen being locked.   While this is not necessarily an Infragistics problem I did come here looking for answers and found none so that's why I am posting.  It turns out that certain controls register for the OnUserPreferenceChanged event which fires when you change your desktop background bitmap or unlock a screensaver.

I believe that some Infragistics controls also register for this event.  The real problem is that in .NET Framework 2.0 the creation of handles for Windows is deferred (allegedly to improve performance).   If you make the mistake I did and fire an asynchrounous thread to go and get some data to fill an Ultragrid before your UI window has a handle,  InvokeRequired will lie to you.    You will think you are on the main UI thread when you are still on the asynch thread.  Then since you are not on a UI thread, messages are not received and the app hangs waiting forever.

A more elegant explanation from someone far brighter than I am:

http://ikriv.com:8765/en/prog/info/dotnet/MysteriousHang.html   (Ivan refers to third party controls such as Infragistics and his sample of the bug with a Freezer app is especially useful in debugging- "E.g., Infragistics library creates a hidden form that it uses for device context measurements. Thus, you may be doing an innocent looking Infragistics call, but it will create a Windows Form and subscribe to the UserPreferenceChanged event. ")

and a solution at:

http://krgreenlee.blogspot.com/2007/09/onuserpreferencechanged-hang.html

Microsoft's knowledge base article was not much help.

http://support.microsoft.com/default.aspx?scid=kb;en-us;943139

I hope this saves someone else from three weeks of banging their head against the wall.