static void Main(string[] args) { CancellationTokenSource cancelTokenSource = new CancellationTokenSource(); FileSystemWatcher watcher = new FileSystemWatcher(@"C:\temp"); watcher.Created += OnFileCreated; host = new JobHost(); // Run the host on a background thread so we can invoke from dashboard host.RunOnBackgroundThread(cancelTokenSource.Token); // Enable the file watcher events and wait watcher.EnableRaisingEvents = true; while (!cancelTokenSource.IsCancellationRequested) { Thread.Sleep(2000); } }