Exemplo n.º 1
0
 static async void ProcessConfig (TriggerConfig triggerConfig, CancellationToken cancellationToken) {
     try {
         switch (triggerConfig.GetTriggerType ()) {
             case TriggerType.File:
                 await WaitForTriggerFileAsync (triggerConfig, cancellationToken);
                 break;
             default:
                 break;
         }
     }
     catch (OperationCanceledException) {
         // expected
     }
 }
Exemplo n.º 2
0
        static async Task WaitForTriggerFileAsync (TriggerConfig triggerConfig, CancellationToken cancellationToken) {
            var triggerFile = triggerConfig.TriggerFile;
            using (var watcher = AsyncFileSystemWatcher.File (triggerFile)) {
                while (!cancellationToken.IsCancellationRequested) {

                    await watcher.WaitForExistanceAsync (cancellationToken);

                    //TODO: temporary
                    if (ActionType.Process != triggerConfig.GetActionType ())
                        return;

                    var process = Process.Start (triggerConfig.ProcessAction.ToProcessStartInfo ());

                    await DeleteAsync (triggerFile, cancellationToken);

                    await process.WaitForExitAsync (cancellationToken);
                }
            }
        }