public void Run() { ILogger logger = new CompoundLogger() { Logs = new ILogger[] { new EventLogger(), new ConsoleLogger() { Verbosity = Verbosity } } }; ChangesMonitor monitor = new ChangesMonitor(logger) { SourcePath = SourcePath, Excludes = Excludes }; ChangesTransmitter transmitter = new ChangesTransmitter(logger) { Host = Host, User = User, PrivateKey = PrivateKey, Passphrase = Passphrase, DestinationPath = DestinationPath, DryRun = DryRun, Excludes = Excludes, }; monitor.TurnOn(); transmitter.WaitChanges(monitor, () => false); }
public void Resync() { ILogger logger = new EventLogger(); ChangesTransmitter transmitter = new ChangesTransmitter(logger) { Host = Host, User = User, PrivateKey = PrivateKey, Passphrase = Passphrase, DestinationPath = DestinationPath, Excludes = Excludes, }; transmitter.Resync(SourcePath); OnStop(); logger.Info("Resync stopping..."); }
public void Start(Predicate cancelPoller) { OnChangesWait(); ILogger logger = new EventLogger(); /// add delegates ChangesMonitor monitor = new ChangesMonitor(logger) { SourcePath = SourcePath, Excludes = Excludes, }; ChangesTransmitter transmitter = new ChangesTransmitter(logger) { Host = Host, User = User, PrivateKey = PrivateKey, Passphrase = Passphrase, DestinationPath = DestinationPath, Excludes = Excludes, }; monitor.OnChangesCollect += OnChangesProcessed; monitor.OnWait += OnChangesWait; monitor.TurnOn(); var cancelListen = new Task(new Action(() => { while (!cancelPoller()) { Thread.Sleep(1000); } //monitor.TurnOff(); transmitter.Stop(); })); cancelListen.Start(); transmitter.WaitChanges(monitor, cancelPoller); OnStop(); logger.Info("Stopping..."); }