Bamboo.Prevalence.Util.SnapshotTaker.Dispose C# (CSharp) Method

Dispose() public method

Cancels the snapshot taking process.
public Dispose ( ) : void
return void
		public void Dispose()
		{
			lock (this)
			{
				if (null != _timer)
				{
					_timer.Dispose();
					_timer = null;						
				}				
			}
		}

Usage Example

		public void TestCleanUpOldFilesPolicy()
		{		
			// some log files...
			Add(20); // 1st log file - 0001.commandlog
			CrashRecover();
			Add(30); // 2nd log file - 0002.commandlog			
			_engine.TakeSnapshot(); // 1st snapshot - 0002.snapshot
			Thread.Sleep(TimeSpan.FromMilliseconds(2500));
			Add(10); // 3rd log file - 0003.commandlog
			
			// remove files older than 2 seconds...
			ICleanUpPolicy policy = new OldFilesCleanUpPolicy(TimeSpan.FromSeconds(2));
			SnapshotTaker taker = new SnapshotTaker(_engine, TimeSpan.FromMilliseconds(250), policy);
			Thread.Sleep(TimeSpan.FromMilliseconds(400));
			// 2nd snasphot taken - 0003.snapshot
			taker.Dispose();

			FileInfo[] files = _engine.PrevalenceBase.GetFiles("*.*");
			Array.Sort(files, FileNameComparer.Default);

            Assert.AreEqual(2, files.Length);
            Assert.AreEqual(FormatCommandLogName(3), files[0].Name, "3rd command log");
            Assert.AreEqual(FormatSnapshotName(3), files[1].Name, "2nd snapshot");

			// sanity check
			CrashRecover();
			AssertTotal(60);
		}
All Usage Examples Of Bamboo.Prevalence.Util.SnapshotTaker::Dispose