Browse files

Merge pull request #93 from konrad-kruczynski/dispatcher_timer_fix

[Fix] Fix for bug #677265 with DispatcherTimer.
  • Loading branch information...
2 parents f9ed937 + 8e4de41 commit 5a35198e2fdb794d48af81d80e783644a29d7291 @migueldeicaza migueldeicaza committed Jul 28, 2011
View
7 mcs/class/WindowsBase/System.Windows.Threading/DispatcherTimer.cs
@@ -66,7 +66,9 @@ public void Start ()
long repeat_interval = interval;
if (repeat_interval == 0)
repeat_interval = 1;
- timer = new Timer (new TimerCallback (timer_tick), null, interval, repeat_interval);
+ timer = new Timer (new TimerCallback (timer_tick),
+ null, new TimeSpan (interval),
+ new TimeSpan (repeat_interval));
}
}
@@ -108,7 +110,8 @@ public void Stop ()
interval = value.Ticks;
if (timer != null)
- timer.Change (interval, interval);
+ timer.Change (new TimeSpan (interval),
+ new TimeSpan (interval));
}
}
View
31 mcs/class/WindowsBase/Test/System.Windows.Threading/DispatcherTimerTest.cs
@@ -0,0 +1,31 @@
+//
+// Tests for System.Windows.Threading.DispatcherTimer
+//
+// Author:
+// Konrad M. Kruczynski
+//
+
+using NUnit.Framework;
+using System;
+using System.Windows.Threading;
+
+namespace MonoTests.System.Windows.Threading
+{
+
+ [TestFixture]
+ public class DispatcherTimerTest {
+
+ [Test]
+ public void IntervalSettingTest ()
+ {
+ var timer = new DispatcherTimer ();
+ var second = new TimeSpan (0, 0, 0, 1);
+ timer.Interval = second;
+ var timerInterval = timer.Interval;
+ Assert.AreEqual (second, timerInterval,
+ "Interval given to timer was not preserved.");
+ }
+
+ }
+}
+
View
1 mcs/class/WindowsBase/WindowsBase_test.dll.sources
@@ -41,3 +41,4 @@ System.Windows.Markup/MarkupExtensionReturnTypeAttributeTest.cs
System.Windows.Markup/ValueSerializerTest.cs
System.Windows.Media/MatrixTest.cs
System.Windows.Threading/DispatcherTest.cs
+System.Windows.Threading/DispatcherTimerTest.cs

0 comments on commit 5a35198

Please sign in to comment.