예제 #1
0
파일: dsotfng.cs 프로젝트: Mnuzz/sc2dsstats
        public void Stop()
        {
            TODO.Clear();
            TODO = null;

            foreach (string path in WATCHER.Keys)
            {
                WATCHER[path].EnableRaisingEvents = false;
                WATCHER[path].Dispose();
                WATCHER[path] = null;
            }

            WATCHER.Clear();
            WATCHER = null;

            foreach (Task task in TASKS.Keys)
            {
                try
                {
                    TASKS[task].Cancel();
                    //task.Wait();
                    TASKS[task].Dispose();
                } catch (AggregateException ex)
                {
                    Console.WriteLine("Task cancel failed :( {0}", ex.InnerExceptions[0].Message);
                }
            }

            TASKS.Clear();
            TASKS = null;
        }
예제 #2
0
        public void Stop()
        {
            _logger.LogInformation("otf stop request.");
            TODO.CollectionChanged -= Source_CollectionChanged;
            TODO.Clear();
            fsBag.Clear();
            foreach (string path in WATCHER.Keys)
            {
                WATCHER[path].EnableRaisingEvents = false;
                WATCHER[path].Dispose();
                WATCHER[path] = null;
            }

            WATCHER.Clear();
            WATCHER = null;

            foreach (Task task in TASKS.Keys)
            {
                try
                {
                    TASKS[task].Cancel();
                    //task.Wait();
                    TASKS[task].Dispose();
                }
                catch (AggregateException ex)
                {
                    _logger.LogError("Task cancel failed :( {0}", ex.InnerExceptions[0].Message);
                }
            }

            TASKS.Clear();
            TASKS   = null;
            Running = false;
            _logger.LogInformation("otf stop.");
        }
예제 #3
0
파일: dsotfng.cs 프로젝트: Mnuzz/sc2dsstats
        private FileSystemWatcher MonitorDirectory(string path)
        {
            FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();

            fileSystemWatcher.IncludeSubdirectories = false;
            fileSystemWatcher.Path                = path;
            fileSystemWatcher.Created            += new FileSystemEventHandler(FileSystemWatcher_Created);
            fileSystemWatcher.EnableRaisingEvents = true;
            if (WATCHER != null && !WATCHER.ContainsKey(path))
            {
                WATCHER.TryAdd(path, fileSystemWatcher);
            }
            fileSystemWatcher.WaitForChanged(WatcherChangeTypes.All);
            return(fileSystemWatcher);
        }
예제 #4
0
        private FileSystemWatcher MonitorDirectory(string path)
        {
            FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(path);

            fileSystemWatcher.IncludeSubdirectories = false;
            //fileSystemWatcher.Path = path;

            fileSystemWatcher.NotifyFilter        = NotifyFilters.FileName | NotifyFilters.LastWrite;
            fileSystemWatcher.EnableRaisingEvents = true;

            //fileSystemWatcher.Created += FileSystemWatcher_Created;
            //fileSystemWatcher.Deleted += FileSystemWatcher_Deleted;
            fileSystemWatcher.Changed += FileSystemWatcher_Changed;
            //fileSystemWatcher.Renamed += FileSystemWatcher_Renamed;
            if (WATCHER != null && !WATCHER.ContainsKey(path))
            {
                WATCHER.TryAdd(path, fileSystemWatcher);
            }
            fileSystemWatcher.WaitForChanged(WatcherChangeTypes.All);
            return(fileSystemWatcher);
        }