diff options
author | Dmitry Potapov <dpotapov@gmail.com> | 2014-02-03 01:41:42 +0400 |
---|---|---|
committer | Dmitry Potapov <dpotapov@gmail.com> | 2014-02-03 01:41:42 +0400 |
commit | ed448193fb32107c219d8445811843ece479a659 (patch) | |
tree | c5b55000d0240d8cdca33023abf282d7e9271204 /mcs/class/WindowsBase | |
parent | 0a339c31a3315f21477c7c5dba71b6818590c02c (diff) |
Dispatcher: Run() can be used more than once
When Run() was invoked a second time, main_execution_frame had the Continue
flag set to false. So it did not work correctly.
Diffstat (limited to 'mcs/class/WindowsBase')
-rw-r--r-- | mcs/class/WindowsBase/System.Windows.Threading/Dispatcher.cs | 3 | ||||
-rw-r--r-- | mcs/class/WindowsBase/Test/System.Windows.Threading/DispatcherTest.cs | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/mcs/class/WindowsBase/System.Windows.Threading/Dispatcher.cs b/mcs/class/WindowsBase/System.Windows.Threading/Dispatcher.cs index f9c11ccc8fe..59a72efdb16 100644 --- a/mcs/class/WindowsBase/System.Windows.Threading/Dispatcher.cs +++ b/mcs/class/WindowsBase/System.Windows.Threading/Dispatcher.cs @@ -334,6 +334,9 @@ namespace System.Windows.Threading { [SecurityCritical] public static void Run () { + // Set Continue, because the previous run could clean + // this flag by Dispatcher.ExitAllFrames. + main_execution_frame.Continue = true; PushFrame (main_execution_frame); } diff --git a/mcs/class/WindowsBase/Test/System.Windows.Threading/DispatcherTest.cs b/mcs/class/WindowsBase/Test/System.Windows.Threading/DispatcherTest.cs index 0980ebb12ba..889b10e2e03 100644 --- a/mcs/class/WindowsBase/Test/System.Windows.Threading/DispatcherTest.cs +++ b/mcs/class/WindowsBase/Test/System.Windows.Threading/DispatcherTest.cs @@ -155,11 +155,17 @@ namespace MonoTests.System.Windows.Threading { Dispatcher d = Dispatcher.CurrentDispatcher; Action exit = delegate { Dispatcher.ExitAllFrames(); }; + int counter = 0; + Action increment = delegate { counter++; }; d.BeginInvoke(DispatcherPriority.Normal, exit); Dispatcher.Run(); + d.BeginInvoke(DispatcherPriority.Normal, increment); + d.BeginInvoke(DispatcherPriority.Normal, increment); d.BeginInvoke(DispatcherPriority.Normal, exit); Dispatcher.Run(); + + Assert.AreEqual(2, counter, "Counter of delegate invocation"); } } } |