コード例 #1
0
        public void IgnoreEventThatTriggeredBeforeSubscription()
        {
            using (var watcher = FileWatcher.For("*.txt")
                                 .InDirectory(targetPath)
                                 .Build())
            {
                HashSet <string> args1 = new HashSet <string>();
                HashSet <string> args2 = new HashSet <string>();

                watcher.Subscribe((ev) => AddCreated(args1, ev));

                File.WriteAllText(Path.Combine(targetPath, "a.txt"), "Hello");

                watcher.CompleteWhenNoChangesFor(100).Wait();

                watcher.Subscribe((ev) => AddCreated(args2, ev));

                File.WriteAllText(Path.Combine(targetPath, "b.txt"), "Hello");

                watcher.CompleteWhenNoChangesFor(100).Wait();

                Execution.Eventually(() =>
                {
                    Assert.That(args1, Does.Contain("a.txt").And.Contain("b.txt"));
                    Assert.That(args2, Does.Contain("b.txt").And.Not.Contain("a.txt"));
                });
            }
        }
コード例 #2
0
        public void Start()
        {
            FileWatcher.For("*.dll")
            .InDirectory(binPath)
            .WatchUntilFirstChange((e, watcher) =>
            {
                Stop();

                watcher.CompleteWhenNoChangesFor(1000).ContinueWith(_ =>
                {
                    Start();
                });
            });

            base.Start();
        }