public static bool GetInstance(out IFileWatcher watcher, bool gamin) { if (InotifyWatcher.failed) { watcher = null; return(false); } if (InotifyWatcher.instance != null) { watcher = InotifyWatcher.instance; return(true); } InotifyWatcher.FD = InotifyWatcher.GetInotifyInstance(); if ((long)InotifyWatcher.FD == -1L) { InotifyWatcher.failed = true; watcher = null; return(false); } InotifyWatcher.watches = Hashtable.Synchronized(new Hashtable()); InotifyWatcher.requests = Hashtable.Synchronized(new Hashtable()); InotifyWatcher.instance = new InotifyWatcher(); watcher = InotifyWatcher.instance; return(true); }
public void StartDispatching(FileSystemWatcher fsw) { ParentInotifyData parentInotifyData; lock (this) { if ((long)InotifyWatcher.FD == -1L) { InotifyWatcher.FD = InotifyWatcher.GetInotifyInstance(); } if (InotifyWatcher.thread == null) { InotifyWatcher.thread = new Thread(new ThreadStart(this.Monitor)); InotifyWatcher.thread.IsBackground = true; InotifyWatcher.thread.Start(); } parentInotifyData = (ParentInotifyData)InotifyWatcher.watches[fsw]; } if (parentInotifyData == null) { InotifyData inotifyData = new InotifyData(); inotifyData.FSW = fsw; inotifyData.Directory = fsw.FullPath; parentInotifyData = new ParentInotifyData(); parentInotifyData.IncludeSubdirs = fsw.IncludeSubdirectories; parentInotifyData.Enabled = true; parentInotifyData.children = new ArrayList(); parentInotifyData.data = inotifyData; InotifyWatcher.watches[fsw] = parentInotifyData; try { InotifyWatcher.StartMonitoringDirectory(inotifyData, false); lock (this) { InotifyWatcher.AppendRequestData(inotifyData); InotifyWatcher.stop = false; } } catch { } } }