Start() public method

public Start ( ) : void
return void
		public void RepeatingWithExceptionsGood() {
			var bkg = new BackgroundRepeater(SometimesException) {
				Cooldown = TimeSpan.FromMilliseconds(1D),
				IsCatchExceptions = true,
			};

			_counter = 0;
			Console.WriteLine(_counter);

			bkg.Start();
			SpinWait.SpinUntil(() => _counter > 100);
			bkg.Stop();

			Console.WriteLine(_counter);

			var c = _counter;
			Thread.Sleep(500);

			if (_counter > c)
				Assert.Fail("repeating not stopped");

			if (4 > c)
				Assert.Fail("where all repeating?");

			Console.WriteLine(_counter);
			Assert.IsFalse(bkg.IsStarted());
		}
		public void MultipleStart() {
			var bkg = new BackgroundRepeater(SingleMethod);
			bkg.Start();
			bkg.Start();
			bkg.Start();
			bkg.Start();
			Assert.IsTrue(bkg.IsStarted());

			bkg.Stop();
			bkg.Stop();
			bkg.Stop();
			Assert.IsFalse(bkg.IsStarted());

			bkg.Start();
			Assert.IsTrue(bkg.IsStarted());
			bkg.Stop();
			Assert.IsFalse(bkg.IsStarted());
			bkg.Stop();
			Assert.IsFalse(bkg.IsStarted());
			bkg.Start();
			bkg.Start();
			bkg.Stop();
			bkg.Stop();

			Assert.IsFalse(bkg.IsStarted());
		}
		public void SelfCancel() {
			var bkg = new BackgroundRepeater(t => {throw new OperationCanceledException();}) {
				Cooldown = TimeSpan.FromMilliseconds(1D),
				IsCatchExceptions = false,
			};
			bkg.Start();
			Thread.Sleep(TimeSpan.FromSeconds(.5D));
			Assert.IsFalse(bkg.IsStarted());
		}
		public void WrongArguments() {
			try {
				Action a = null;
				var bkg = new BackgroundRepeater(a);
				Console.WriteLine("Wtf??");
				bkg.Start();
				Console.WriteLine("Wtf??!!!");
				Assert.Fail("Where ArgumentNullException?");
			} catch (ArgumentNullException) {
				Console.WriteLine("OK: Action == null");
			}

			try {
				Action<CancellationToken> a = null;
				var bkg = new BackgroundRepeater(a);
				Console.WriteLine("Wtf?? (2)");
				bkg.Start();
				Console.WriteLine("Wtf??!!! (2)");
				Assert.Fail("Where ArgumentNullException? (2)");
			} catch (ArgumentNullException) {
				Console.WriteLine("OK: Action<CancellationToken> == null");
			}
		}
		public void RepeatingWithExceptionsFail() {
			var bkg = new BackgroundRepeater(SometimesException) {
				Cooldown = TimeSpan.FromMilliseconds(1D),
				IsCatchExceptions = false,
			};

			_counter = 0;
			bkg.Start();

			SpinWait.SpinUntil(() => _counter == 4);
			Thread.Sleep(TimeSpan.FromSeconds(1D));

			Assert.IsTrue(_counter == 4);
			Assert.IsFalse(bkg.IsStarted());
		}