public void Stop()
{
try
{
// Check if the capture device is even running
if (IsRunning)
{
// Yes, stop via the event
StopSignal.Set();
// Abort the thread
Worker.Abort();
if (Worker != null)
{
// Join
Worker.Join();
// Release
Release();
}
}
}
catch (Exception ex)
{
// Trace
Trace.TraceError(ex.Message);
// Release
Release();
}
}
/// <summary> /// Cleans up a specific device /// </summary> /// <param name="device">Device to clean up</param> void CleanUpDevice(CapDevice device) { // Check if there even is a device if (device == null) { return; } // Stop device.Stop(); // Unsubscribe device.NewBitmapReady -= device_OnNewBitmapReady; }