Beispiel #1
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))
                {
                    throw thrownException;
                }
            },
                                         (ex, error) =>
            {
                thrownException = ex;
                Errors          = error;
            },
                                         Token);

            wrapper.Run();

            return(result);
        }
Beispiel #2
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))
                {
                    throw thrownException;
                }
            },
                                         (ex, error) =>
            {
                thrownException = ex;
                Errors          = error;
            },
                                         Token);
            wrapper.Run();

            return(result);
        }
Beispiel #3
0
 protected override void RaiseOnStart()
 {
     base.RaiseOnStart();
     OnStartProcess?.Invoke(this);
 }
 public virtual void AddProcess(CraftingRecipe recipe)
 {
     // Assign the new recipe and tell listeners about it
     _processing = recipe;
     OnStartProcess?.Invoke(recipe);
 }
Beispiel #5
0
 /// <summary>
 /// Called when the process has been started.
 /// </summary>
 protected virtual void RaiseOnStartProcess()
 {
     OnStartProcess?.Invoke(this);
 }
Beispiel #6
0
 public void SetOnStartProcess(string description, bool showProgressBar = true)
 {
     OnStartProcess?.Invoke(this, new ProcessArgs(0, description, "", showProgressBar));
 }