Esempio n. 1
0
        protected override T RunWithReturn(bool success)
        {
            T result = base.RunWithReturn(success);

            try
            {
                if (Callback != null)
                {
                    result = Callback(success);
                }
                else if (CallbackWithException != null)
                {
                    var thrown = GetThrownException();
                    result = CallbackWithException(success, thrown);
                }
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(result);
        }
Esempio n. 2
0
        protected override void Run(bool success)
        {
            base.Run(success);

            Token.ThrowIfCancellationRequested();
            try
            {
                if (task.Status == TaskStatus.Created && !task.IsCompleted &&
                    ((task.CreationOptions & (TaskCreationOptions)512) == TaskCreationOptions.None))
                {
                    var scheduler = TaskManager.GetScheduler(Affinity);
                    Token.ThrowIfCancellationRequested();
                    task.RunSynchronously(scheduler);
                }
                else
                {
                    task.Wait();
                }
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
                Token.ThrowIfCancellationRequested();
            }
        }
Esempio n. 3
0
        protected override T RunWithReturn(bool success)
        {
            var result = base.RunWithReturn(success);

            wrapper = new ProcessWrapper(Name, Process, outputProcessor,
                                         () => OnStartProcess?.Invoke(this),
                                         () =>
            {
                try
                {
                    if (outputProcessor != null)
                    {
                        result = outputProcessor.Result;
                    }

                    if (typeof(T) == typeof(string) && result == null && !Process.StartInfo.CreateNoWindow)
                    {
                        result = (T)(object)"Process running";
                    }

                    if (!String.IsNullOrEmpty(Errors))
                    {
                        OnErrorData?.Invoke(Errors);
                    }
                }
                catch (Exception ex)
                {
                    if (thrownException == null)
                    {
                        thrownException = new ProcessException(ex.Message, ex);
                    }
                    else
                    {
                        thrownException = new ProcessException(thrownException.GetExceptionMessage(), ex);
                    }
                }

                if (thrownException != null && !RaiseFaultHandlers(thrownException))
                {
                    ThrownException.Rethrow();
                }
            },
                                         (ex, error) =>
            {
                thrownException = ex;
                Errors          = error;
            },
                                         Token);

            wrapper.Run();

            return(result);
        }
Esempio n. 4
0
        protected override List <T> RunWithReturn(bool success)
        {
            var result = base.RunWithReturn(success);

            wrapper = new ProcessWrapper(Name, Process, outputProcessor,
                                         () => OnStartProcess?.Invoke(this),
                                         () =>
            {
                try
                {
                    if (outputProcessor != null)
                    {
                        result = outputProcessor.Result;
                    }
                    if (result == null)
                    {
                        result = new List <T>();
                    }

                    if (!String.IsNullOrEmpty(Errors))
                    {
                        OnErrorData?.Invoke(Errors);
                    }
                }
                catch (Exception ex)
                {
                    if (thrownException == null)
                    {
                        thrownException = new ProcessException(ex.Message, ex);
                    }
                    else
                    {
                        thrownException = new ProcessException(thrownException.GetExceptionMessage(), ex);
                    }
                }

                if (thrownException != null && !RaiseFaultHandlers(thrownException))
                {
                    ThrownException.Rethrow();
                }
            },
                                         (ex, error) =>
            {
                thrownException = ex;
                Errors          = error;
            },
                                         Token);
            wrapper.Run();

            return(result);
        }
Esempio n. 5
0
        protected override GitInstallationState RunWithReturn(bool success)
        {
            var ret = base.RunWithReturn(success);

            try
            {
                ret = SetupGitIfNeeded();
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(ret);
        }
Esempio n. 6
0
        protected override NPath RunWithReturn(bool success)
        {
            var ret = BaseRun(success);

            try
            {
                ret = RunUnzip(success);
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(ret);
        }
Esempio n. 7
0
        protected override NPath RunWithReturn(bool success)
        {
            var result = base.RunWithReturn(success);

            try
            {
                result = RunDownload(success);
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(result);
        }
Esempio n. 8
0
 protected override void Run(bool success)
 {
     base.Run(success);
     try
     {
         Callback?.Invoke(success);
         if (CallbackWithException != null)
         {
             var thrown = GetThrownException();
             CallbackWithException?.Invoke(success, thrown);
         }
     }
     catch (Exception ex)
     {
         if (!RaiseFaultHandlers(ex))
         {
             ThrownException.Rethrow();
         }
     }
 }