protected override void OnStart(string[] args) { try { var configuration = new AutoPosterConfig(); watcher = new Watcher(configuration); watcher.Start(); log.Info("FileSystemWatcher started"); poster = new AutoPoster(configuration); poster.Start(); log.Info("Autoposter started"); notifier = new IndexerNotifier(configuration); notifier.Start(); log.Info("Notifier started"); verifier = new IndexerVerifier(configuration); verifier.Start(); log.Info("Verifier started"); } catch (Exception ex) { log.Fatal("Fatal exception when starting the autoposter.", ex); throw; } }
public AutoPoster(AutoPosterConfig configuration) { this.configuration = configuration; posterConfiguration = new UsenetPosterConfig(); poster = new UsenetPoster(posterConfiguration); StopRequested = false; MyTask = new Task(AutopostingTask, TaskCreationOptions.LongRunning); }
static void Main(string[] args) { try { var configuration = new AutoPosterConfig(); Watcher watcher = new Watcher(configuration); watcher.Start(); log.Info("FileSystemWatcher started"); Console.WriteLine("FileSystemWatcher started"); AutoPoster poster = new AutoPoster(configuration); poster.Start(); log.Info("Autoposter started"); Console.WriteLine("Autoposter started"); IndexerNotifier notifier = new IndexerNotifier(configuration); notifier.Start(); log.Info("Notifier started"); Console.WriteLine("Notifier started"); IndexerVerifier verifier = new IndexerVerifier(configuration); verifier.Start(); log.Info("Verifier started"); Console.WriteLine("Verifier started"); Console.WriteLine("Press the \"s\" key to stop after the current operations have finished."); Boolean stop = false; while (!stop) { var keyInfo = Console.ReadKey(); stop = keyInfo.KeyChar == 's' || keyInfo.KeyChar == 'S'; } watcher.Stop(); log.Info("FileSystemWatcher stopped"); Console.WriteLine("FileSystemWatcher stopped"); verifier.Stop(); log.Info("Verifier stopped"); Console.WriteLine("Verifier stopped"); notifier.Stop(); log.Info("Notifier stopped"); Console.WriteLine("Notifier stopped"); poster.Stop(); log.Info("Autoposter stopped"); Console.WriteLine("Autoposter stopped"); } catch(Exception ex) { log.Fatal("Fatal exception when starting the autoposter.", ex); throw; } }
public IndexerVerifier(AutoPosterConfig configuration) { this.configuration = configuration; StopRequested = false; MyTask = new Task(IndexerVerifierTask, TaskCreationOptions.LongRunning); }