Example #1
0
        public void Start()
        {
            // file system watcher will fail if directory isn't there, ensure it is
            if (!Directory.Exists(_baseDirectory))
                Directory.CreateDirectory(_baseDirectory);

            _scheduler = new TimerScheduler(new PoolFiber());
            _channel = new ChannelAdapter();

            _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, new PoolFiber(),
                                                           2.Minutes());

            _connection = _channel.Connect(config =>
                {
                    config
                        .AddConsumerOf<FileSystemEvent>()
                        .BufferFor(3.Seconds())
                        .UseScheduler(_scheduler)
                        .Distinct(fsEvent => GetChangedDirectory(fsEvent.Path))
                        .UsingConsumer(fsEvents =>
                            {
                                fsEvents.Keys.Distinct().Each(key =>
                                    {
                                        if (key == _baseDirectory)
                                            return;

                                        _serviceChannel.Send(new ServiceFolderChanged(key));
                                    });
                            })
                        .HandleOnFiber(_fiber);
                });
        }
Example #2
0
        public void Start()
        {
            // file system watcher will fail if directory isn't there, ensure it is
            if (!Directory.Exists(_baseDirectory))
                Directory.CreateDirectory(_baseDirectory);

            _scheduler = new TimerScheduler(new PoolFiber());
            _channel = new ChannelAdapter();

            _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, new PoolFiber(),
                                                           10.Minutes());

            _connection = _channel.Connect(x =>
                {
                    x.AddConsumerOf<FileSystemEvent>()
                        .UsingConsumer(msg => ScheduleFolderChangeNotification(GetChangedDirectory(msg.Path)))
                        .HandleOnFiber(_fiber);
                });
        }
Example #3
0
        public void Start()
        {
            // file system watcher will fail if directory isn't there, ensure it is
            if (!Directory.Exists(_baseDirectory))
            {
                Directory.CreateDirectory(_baseDirectory);
            }

            _scheduler = new TimerScheduler(new PoolFiber());
            _channel   = new ChannelAdapter();

            _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, new PoolFiber(),
                                                           10.Minutes());

            _connection = _channel.Connect(x =>
            {
                x.AddConsumerOf <FileSystemEvent>()
                .UsingConsumer(msg => ScheduleFolderChangeNotification(GetChangedDirectory(msg.Path)))
                .HandleOnFiber(_fiber);
            });
        }
Example #4
0
        public void Stop()
        {
            if (_producer != null)
            {
                _producer.Dispose();
                _producer = null;
            }

            if (_scheduler != null)
            {
                _scheduler.Stop(30.Seconds());
                _scheduler = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }

            _channel = null;
        }
Example #5
0
        public void Stop()
        {
            if (_producer != null)
            {
                _producer.Dispose();
                _producer = null;
            }

            _pendingNotifications.Each(x => x.Value.Cancel());

            if (_scheduler != null)
            {
                _scheduler.Stop(30.Seconds());
                _scheduler = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }

            _channel = null;
        }
Example #6
0
        public void Start()
        {
            // file system watcher will fail if directory isn't there, ensure it is
            if (!Directory.Exists(_baseDirectory))
            {
                Directory.CreateDirectory(_baseDirectory);
            }

            _scheduler = new TimerScheduler(new PoolFiber());
            _channel   = new ChannelAdapter();

            _producer = new PollingFileSystemEventProducer(_baseDirectory, _channel, _scheduler, new PoolFiber(),
                                                           2.Minutes());

            _connection = _channel.Connect(config =>
            {
                config
                .AddConsumerOf <FileSystemEvent>()
                .BufferFor(3.Seconds())
                .UseScheduler(_scheduler)
                .Distinct(fsEvent => GetChangedDirectory(fsEvent.Path))
                .UsingConsumer(fsEvents =>
                {
                    fsEvents.Keys.Distinct().Each(key =>
                    {
                        if (key == _baseDirectory)
                        {
                            return;
                        }

                        _serviceChannel.Send(new ServiceFolderChanged(key));
                    });
                })
                .HandleOnFiber(_fiber);
            });
        }
Example #7
0
        public void Stop()
        {
            if (_producer != null)
            {
                _producer.Dispose();
                _producer = null;
            }

            if (_scheduler != null)
            {
                _scheduler.Stop(30.Seconds());
                _scheduler = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }

            _channel = null;
        }
Example #8
0
        public void Stop()
        {
            if (_producer != null)
            {
                _producer.Dispose();
                _producer = null;
            }

            _pendingNotifications.Each(x => x.Value.Cancel());

            if (_scheduler != null)
            {
                _scheduler.Stop(30.Seconds());
                _scheduler = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }

            _channel = null;
        }