Exemplo n.º 1
0
		public async Task Stop()
		{
			var timerExpired = false;
			var syncTimer = new SyncTimer(() => {
				timerExpired = true;
			});
			syncTimer.Start(120);
			await Task.Delay(50);
			syncTimer.Stop();
			await Task.Delay(120);
			Assert.AreEqual(false, timerExpired);
		}
Exemplo n.º 2
0
		public async Task StartWithInt32()
		{
			var timerExpired = false;
			SynchronizationContext sc = null;
			var syncTimer = new SyncTimer(() => {
				timerExpired = true;
				sc = SynchronizationContext.Current;
			});
			syncTimer.Start(50);
			await Task.Delay(120);
			Assert.AreEqual(true, timerExpired);
			Assert.AreSame(_fakeSynchronizationContext, sc);
		}
Exemplo n.º 3
0
		public async Task StopsWhenDisposed()
		{
			var timerExpired = false;
			var syncTimer = new SyncTimer(() => {
				timerExpired = true;
			});
			syncTimer.Start(500);
			syncTimer.Dispose();
			await Task.Delay(600);
			Assert.AreEqual(false, timerExpired);
		}