/// <summary>
 /// Throws ExternalProcessFailureException
 /// </summary>
 async public Task Wait(ExternalProcess.AsyncTaskDescriptor descriptor)
 {
     _descriptors.Add(descriptor);
     try
     {
         await descriptor.Task;
     }
     finally
     {
         descriptor.Process.Dispose();
         _descriptors.Remove(descriptor);
     }
 }
        private void cancelOperation(ExternalProcess.AsyncTaskDescriptor descriptor)
        {
            if (descriptor == null)
            {
                return;
            }

            descriptor.Cancelled = true;
            try
            {
                ExternalProcess.Cancel(descriptor.Process);
            }
            catch (InvalidOperationException)
            {
                // process already exited
            }
        }
Exemple #3
0
        async public static Task <bool> DoesEntityExistAtPathAsync(
            IExternalProcessManager operationManager, string path, string entity)
        {
            string arguments = String.Format("cat-file -t {0}", entity);

            try
            {
                ExternalProcess.AsyncTaskDescriptor descriptor =
                    operationManager?.CreateDescriptor("git", arguments, path, null, null);
                if (descriptor == null)
                {
                    return(false);
                }

                await operationManager.Wait(descriptor);

                return(descriptor.StdErr.Count() == 0);
            }
            catch (Exception) // Exception type does not matter
            {
                return(false);
            }
        }
 public void Cancel(ExternalProcess.AsyncTaskDescriptor descriptor)
 {
     cancelOperation(descriptor);
 }