Beispiel #1
0
        private void fsWather_Changed(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                if (_hstbWather.ContainsKey(e.FullPath))
                {
                    WatcherChangeTypes oldType = ((FileSystemEventArgs)_hstbWather[e.FullPath]).ChangeType;
                    if (oldType == WatcherChangeTypes.Created || oldType == WatcherChangeTypes.Changed)
                    {
                        return;
                    }
                }
            }

            lock (_hstbWather)
            {
                if (!_hstbWather.ContainsKey(e.FullPath))
                {
                    _hstbWather.Add(e.FullPath, e);
                }
            }
            var watcherProcess = new WatcherProcess(sender, e);

            watcherProcess.OnChanged   += OnChanged; //传递事件
            watcherProcess.OnCompleted += WatcherProcess_OnCompleted;
            var thread = new Thread(watcherProcess.Process);

            thread.Start();
        }
Beispiel #2
0
        private void fsWather_Created(object sender, FileSystemEventArgs e)
        {
            lock (_hstbWather)
            {
                if (!_hstbWather.ContainsKey(e.FullPath))
                {
                    _hstbWather.Add(e.FullPath, e);
                }
            }
            var watcherProcess = new WatcherProcess(sender, e);

            watcherProcess.OnCreated   += OnCreated; //传递事件
            watcherProcess.OnCompleted += WatcherProcess_OnCompleted;
            var threadDeal = new Thread(watcherProcess.Process);

            threadDeal.Start();
        }