Example #1
0
        private void OnStart(int id, string folder, IList <KeyValuePair <string, string> > results)
        {
            Report(results, String.Format("Called OnStart to watch {0}", folder));
            lock (data)
            {
                if (!data.ContainsKey(id))
                {
                    data.Add(id, new List <String>());
                }
            }

            lock (watchers)
            {
                if (watchers.ContainsKey(folder))
                {
                    watchers[folder].AddProcess(id);
                }
                else
                {
                    IndexedWatcher newWatcher = new IndexedWatcher(folder, "*.*", new FileSystemEventHandler(FileEventHandler));
                    watchers.Add(folder, newWatcher);
                    newWatcher.AddProcess(id);
                }
            }
        }
Example #2
0
        private void FileEventHandler(Object sender, FileSystemEventArgs e)
        {
            IndexedWatcher watcher = sender as IndexedWatcher;
            string         str     = String.Format("{0} {1}", e.FullPath, e.ChangeType);

            lock (watcher.ProcessesWatching)
                lock (data)
                {
                    foreach (int id in watcher.ProcessesWatching)
                    {
                        data[id].Add(str);
                    }
                }
        }