fixed crash with sd setup

This commit is contained in:
NicoAICP 2020-06-14 11:30:44 +02:00
parent 1f0d9ce671
commit 045b5ac345

View file

@ -73,17 +73,35 @@ namespace UWUVCI_AIO_WPF.UI.Windows
WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2"); WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2");
watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); watcher.EventArrived += new EventArrivedEventHandler(watcher_EventArrived);
watcher.Query = query; watcher.Query = query;
watcher.Options.Timeout = new TimeSpan(0, 0, 5);
watcher.Start(); watcher.Start();
try
{
watcher.WaitForNextEvent(); watcher.WaitForNextEvent();
} }
catch (Exception)
{
}
}
private void checkfornewoutput() private void checkfornewoutput()
{ {
WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 3"); WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 3");
watcher2.EventArrived += new EventArrivedEventHandler(watcher_EventArrived); watcher2.EventArrived += new EventArrivedEventHandler(watcher_EventArrived);
watcher2.Query = query; watcher2.Query = query;
watcher2.Options.Timeout = new TimeSpan(0, 0, 5);
watcher2.Start(); watcher2.Start();
try
{
watcher2.WaitForNextEvent(); watcher2.WaitForNextEvent();
} }
catch (Exception)
{
}
}
private void watcher_EventArrived(object sender, EventArrivedEventArgs e) private void watcher_EventArrived(object sender, EventArrivedEventArgs e)
{ {
@ -157,7 +175,8 @@ namespace UWUVCI_AIO_WPF.UI.Windows
watcher.Stop(); watcher.Stop();
watcher2.Stop(); watcher2.Stop();
watcher.Dispose();
watcher2.Dispose();
this.Close(); this.Close();
} }
private void close_MouseLeave(object sender, MouseEventArgs e) private void close_MouseLeave(object sender, MouseEventArgs e)