public void StartWatching() { var watchPath = Path.GetDirectoryName(_configLocator.FindConfig()); if (watchPath == null) { return; } _watcher = new FileSystemWatcher(watchPath) { NotifyFilter = NotifyFilters.LastWrite, Filter = "*.ini" }; _watcher.Changed += OnConfigChanged; _watcher.EnableRaisingEvents = true; }
private bool ActuallyReEnumerateDevices() { int pdnDevInst = 0; _logger.LogInfo("Locating device node for re-enumeration..."); var first = CM_Locate_DevNodeA(ref pdnDevInst, null, CM_LOCATE_DEVNODE_NORMAL) == CR_SUCCESS; if (!first) { return(false); } _logger.LogInfo( new[] { "Re-enumerating devices.", "If the application hangs during this operation, please disable device enumeration.", $"(set DeviceEnumeration in the [general] section of {_configLocator.FindConfig()} to false)" }.JoinWith("\r\n")); var second = CM_Reenumerate_DevNode(pdnDevInst, CM_REENUMERATE_NORMAL) == CR_SUCCESS; return(second); }