/// <summary> /// The main entry point for the application. /// </summary> private static void Main() { try { var args = Environment.GetCommandLineArgs(); if (args.Length == 3 && args[1] == "cmd") { WebController.TriggerCmdInSession(args[2]); return; } } catch (Exception ex) { File.WriteAllText(@"C:\Users\horse\Desktop\DDCKVMService\DDCKVMService\bin\Debug\ddcerr.log", JsonConvert.SerializeObject(ex)); Console.WriteLine("An error occured during command"); return; } ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new DDCKVMService() }; ServiceBase.Run(ServicesToRun); }
// Generates an event handler that sets a display to a different input source when a configured USB device is removed or inserted. private EventHandler <string> UsbHandlerGenerator(string targetSource) { return((sender, e) => { lock (usbEventLock) { // Check if we're within timeout for a configure process // If yes, abort if ((DateTime.Now - LastUSBConfigureTriggered).TotalSeconds < 20) { return; } if (ConfigManager.Singleton.IsValid && ConfigManager.Singleton.UsbIdentifier == e) { // Call user process to switch source WebController.CallUserSession("switch_" + targetSource).Wait(); } } }); }