/// <summary> /// Represents the entry point of our application. /// </summary> /// <param name="args">Possibly spcified command line arguments.</param> public static void Main(string[] args) { RemovableDriveWatcher rdw = new RemovableDriveWatcher(); // Create a new instance of the RemoveableDriveWatcher class. rdw.NewDriveFound += NewDriveFound; // Connect to the "NewDriveFound" event. rdw.DriveRemoved += DriveRemoved; // Connect to the "DriveRemoved" event. rdw.Start(); // Start watching. // Do something here... Console.ReadLine(); rdw.Stop(); // Stop watching. }
/// <summary> /// Initializes a new instance of the <see cref="Library"/> class. /// </summary> public Library() { this.songLock = new object(); this.songs = new HashSet <Song>(); this.playlist = new Playlist(); this.volume = 1.0f; this.AccessMode = AccessMode.Administrator; // We want implicit to be the administrator, till we change to user mode manually this.driveWatcher = RemovableDriveWatcher.Create(); this.driveWatcher.DriveRemoved += (sender, args) => Task.Factory.StartNew(this.Update); this.cacheResetHandle = new AutoResetEvent(false); this.disposeLock = new object(); }