private static void AccessEcSynchronized(Action <IEmbeddedController> callback, IEmbeddedController ec) { if (ec.AcquireLock(200)) { try { callback(ec); } finally { ec.ReleaseLock(); } } }
private static void AccessEcSynchronized(Action <IEmbeddedController> callback, IEmbeddedController ec) { if (ec.AcquireLock(200)) { try { callback(ec); } finally { ec.ReleaseLock(); } } else { Console.Error.WriteLine("Could not acquire EC lock"); } }
private static void AccessEcSynchronized(Action <IEmbeddedController> callback) { var ecLoader = new FanControlPluginLoader <IEmbeddedController>(FanControl.PluginsDirectory); IEmbeddedController ec = ecLoader.FanControlPlugin; ec.Initialize(); if (ec.AcquireLock(200)) { try { callback(ec); } finally { ec.ReleaseLock(); } } else { Console.Error.WriteLine("Error connecting to Embedded Controller"); } }
static void Main(string[] args) { AppDomain.CurrentDomain.ProcessExit += (s, e) => { if (ec != null) { try { ec.ReleaseLock(); ec.Dispose(); } catch { } } }; try { ParseArgs(args); } catch (Exception e) { Console.Error.WriteLine(e.Message); } }