Microsoft KB Archive/937128

= BUG: You may encounter a deadlock condition when you call the Dispatcher.Invoke method in a Windows Presentation Foundation application =

Article ID: 937128

Article Last Modified on 6/8/2007

-

APPLIES TO


 * Microsoft .NET Framework 3.0

-



SYMPTOMS
When you call the Dispatcher.Invoke method in a Microsoft Windows Presentation Foundation application, you may encounter a deadlock condition. The deadlock condition may make the mouse stop responding.



CAUSE
This problem occurs when you call the Dispatcher.Invoke method during an operation that is known as the move-size loop. This operation sizes a window, or this operation moves a window.

The Dispatcher class supports synchronous invocation of operations and synchronous waiting for operations on the current thread. To do this, the Dispatcher class processes all the other operations that have a higher priority first. Next, the Dispatcher class processes the specified operation. Then, the Dispatcher class returns to the caller. Additionally, the Dispatcher class does not invoke operations that have a lower priority than the DispatcherPriority.Input enumeration value or that have an equal priority to the DispatcherPriority.Input enumeration value until the system has processed all the pending input.

A scenario exists in which an operation that has a lower priority than the DispatcherPriority.Input enumeration value or that has an equal priority to the DispatcherPriority.Input enumeration value is invoked synchronously. If this operation is invoked during the move-size loop, the invocation may never finish. The invocation may never finish because a Microsoft Win32 timer is set. The Win32 timer starts only when the system has processed the higher priority input. However, Win32 has compatibility code that forces the GetMessage method not to process any pending input during the move-size loop. Therefore, the GetMessage method processes the Win32 timer instead. The WM_TIMER message is dispatched. But, another timer is set because input is still pending. An infinite loop occurs. Because the infinite loop occurs during the move-size loop, the Windows Presentation Foundation application may stop responding. Additionally, the mouse may stop responding.



WORKAROUND
To work around this problem, you can switch to another window by pressing ALT+TAB or by pressing CTRL+ALT+DELETE. This action restores some mouse functionality.

If you are programming a Windows Presentation Foundation application, review the code to determine whether you may have introduced this problem.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
For more information about how to use Windows Presentation Foundation, visit the following Microsoft Web site:

http://wpf.netfx3.com/

Keywords: kbprb kbexpertiseadvanced kbtshoot kbbug KB937128

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.