/// <summary> /// Initialize the logging process for a device /// </summary> /// <param name="device"> The device to be logged </param> public static void InitializeLogging(DeviceData device) { var accessData = new AccessData(device); var cts = new CancellationTokenSource(); LoggingManager.AddEntry(device.Serial, cts); ThreadPool.QueueUserWorkItem(accessData.CheckDeviceState, cts.Token); }
/// <summary> /// Display a toast /// </summary> /// <param name="sender"> The sender </param> /// <param name="e"> Event to recognize devices </param> private static void OnDeviceDisconnected(object sender, DeviceDataEventArgs e) { ThreadPool.SetMaxThreads(GetConnectedDevices().Count, GetConnectedDevices().Count); LoggingManager.DeleteEntry(e.Device.Serial); Console.WriteLine($"The device {e.Device} has disconnected from this PC"); RecController.StopScrRec(e.Device); if (MarkerList.ActiveDeviceData is not null && MarkerList.ActiveDeviceData.Serial.Equals(e.Device.Serial)) { MarkerList.ActiveDeviceData = null; } }
/// <summary> /// Determines if a device is logging /// </summary> /// <param name="device"></param> /// <returns> true if the device is logging </returns> public static bool DeviceIsLogging(DeviceData device) { return(LoggingManager.GetLoggingDevices().ContainsKey(device.Serial)); }
/// <summary> /// Stop the logging process for a specified device /// </summary> /// <param name="device"> The specified device </param> /// <returns> true for success and false for failure </returns> public static bool StopLogging(DeviceData device) { return(LoggingManager.DeleteEntry(device.Serial)); }