Exemplo n.º 1
0
        public event Notify ProcessCompleted; // event

        public void StartProcess()
        {
            Console.WriteLine("Subcribe clicked!");
            // some code here..
            // OnProcessCompleted();
            ProcessCompleted?.Invoke();
        }
Exemplo n.º 2
0
        private void Exec()
        {
            NetUtil = new Process();
            NetUtil.StartInfo.FileName               = "net.exe";
            NetUtil.StartInfo.CreateNoWindow         = true;
            NetUtil.StartInfo.Arguments              = "view";
            NetUtil.StartInfo.RedirectStandardOutput = true;
            NetUtil.StartInfo.UseShellExecute        = false;
            NetUtil.StartInfo.RedirectStandardError  = true;
            NetUtil.Start();
            using (var reader = new StreamReader(NetUtil.StandardOutput.BaseStream, NetUtil.StandardOutput.CurrentEncoding))
            {
                string line = "";

                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("\\", StringComparison.OrdinalIgnoreCase))
                    {
                        var name = line.Substring(2);
                        var idx  = name.IndexOf(' ');
                        name = name.Substring(0, idx);

                        ComputerNames.Add(name);
                    }
                }
            }
            NetUtil.WaitForExit();
            ProcessCompleted?.Invoke(this, EventArgs.Empty);
        }
 protected void OnProcessCompleted()
 {
     InvokeInUiThread(() =>
     {
         ProcessCompleted?.Invoke(this, _action);
     });
 }
        protected void OnProcessCompleted(TerminalProcessingOutcome po)
        {
            try
            {
                if (po == null) //exception occurred
                {
                    return;
                }

                switch (po.NextProcessState)
                {
                case EMVTerminalPreProcessingStateEnum.EndProcess:
                    cardQProcessor.StopServiceQProcess();
                    ProcessCompleted?.Invoke(this, new TerminalProcessingOutcomeEventArgs()
                    {
                        TerminalProcessingOutcome = po
                    });
                    break;

                default:
                    throw new DesFireException("Unimplemeted TerminalPreProcessingStateEnum in OnProcessCompleted");
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Error in OnProcessCompleted:" + ex.Message);
                return;
            }
        }
Exemplo n.º 5
0
 // metod koji ispaljuje dogadjaj
 protected virtual void FireProcessCompleted(ProcessEventArgs e)
 {
     if (ProcessCompleted != null)
     {
         ProcessCompleted.Invoke(this, e);
     }
 }
 private Task NofificarFin(JobResult jobResult)
 {
     return (ProcessCompleted?.Invoke(this, new ExecutorCompleteEventArgs()
     {
         JobId = this.JobId,
         OutputJob = jobResult.OutputJob,
         FechaFin = DateTime.Now
     }) ?? Task.CompletedTask);//.ConfigureAwait(false);
 }
Exemplo n.º 7
0
 void OnProcessCompleted()  //protected virtual method step3
 {
     //if ProcessCompleted is not null then call delegate
     if (ProcessCompleted != null)
     {
         ProcessCompleted.Invoke();
     }
     // ProcessCompleted?.Invoke(); //step4
 }
Exemplo n.º 8
0
        public void StartProcess()
        {
            Console.WriteLine("Process Started!");
            // some code here..
            //  OnProcessCompleted(EventArgs.Empty); //No event data

            ProcessCompleted?.Invoke(this, EventArgs.Empty);
            Console.ReadLine();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Called, when a process has been completed.
        /// </summary>
        protected virtual void OnProcessCompleted(long streamLength, TimeSpan elapsedTime, ChunkEventArgs.ProcessType type)
        {
            var args = new ChunkEventArgs();

            args.CompletedChunks = (int)(Math.Ceiling(streamLength / (float)_chunkSize));
            args.TotalChunks     = args.CompletedChunks;
            args.TotalTime       = elapsedTime;
            args.Type            = type;

            ProcessCompleted?.Invoke(this, args);
        }
Exemplo n.º 10
0
 public void check()
 {
     Console.WriteLine("Leave application process Started!");
     if (AvailLeaves >= NoOfLeaves)
     {
         ProcessCompleted?.Invoke();
     }
     else
     {
         Console.WriteLine("Leaves not available.");
     }
 }
Exemplo n.º 11
0
 protected void OnProcessCompleted(EMVTerminalProcessingOutcome po)
 {
     try
     {
         TerminalProcessingOutcomeEventArgs tpo = new TerminalProcessingOutcomeEventArgs()
         {
             TerminalProcessingOutcome = po
         };
         ProcessCompleted?.Invoke(this, tpo);
     }
     catch (Exception ex)
     {
         Logger.Log("Error in OnProcessCompleted:" + ex.Message);
         return;
     }
 }
Exemplo n.º 12
0
        ///<summary>
        ///Iterates through all the WorkUnits until the producer calls CompleteAdding() and all added WorkUnits have been processed.
        ///</summary>
        public void Begin()
        {
            // if the external process doesn't set up a process, just pass the value along
            if (ProcessCompleted.GetInvocationList().Count() == 0 && PassValuesIfNoProcessDelegate)
            {
                Process = w =>
                {
                    return(w);
                };
            }

            Task.Run(() =>
            {
                InnerWorkLoop();
            });
        }
        protected void OnProcessCompleted(EMVTerminalProcessingOutcome po)
        {
            try
            {
                if (po == null) //exception occurred
                {
                    return;
                }

                switch (po.NextProcessState)
                {
                case EMVTerminalPreProcessingStateEnum.ProtocolActivation_StartB:
                    DoEntryPointB(EMVTerminalPreProcessingStateEnum.ProtocolActivation_StartB);
                    break;

                case EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC:
                    DoEntryPointC(EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC);
                    break;

                case EMVTerminalPreProcessingStateEnum.EndProcess:
                    //cardQProcessor.StopServiceQProcess();
                    TerminalProcessingOutcomeEventArgs tpo = new TerminalProcessingOutcomeEventArgs()
                    {
                        TerminalProcessingOutcome = po
                    };
                    ProcessCompleted?.Invoke(this, tpo);
                    break;

                default:
                    throw new EMVProtocolException("Unimplemeted TerminalPreProcessingStateEnum in OnProcessCompleted");
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Error in OnProcessCompleted:" + ex.Message);
                return;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Runs specified application with specified arguments.
        /// </summary>
        /// <param name="fileName">The application to start.</param>
        /// <param name="arguments">The set of arguments to use when starting the application.</param>
        /// <returns>The process completion status.</returns>
        /// <exception cref="System.IO.FileNotFoundException">Occurs when the file to run is not found.</exception>
        /// <exception cref="InvalidOperationException">Occurs when this class instance is already running another process.</exception>
        public virtual CompletionStatus Run(string fileName, string arguments)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Filename cannot be null or empty.", nameof(fileName));
            }
            if (!fileSystem.Exists(fileName))
            {
                throw new System.IO.FileNotFoundException(string.Format(@"File ""{0}"" is not found.", fileName));
            }
            IProcess P;

            lock (lockToken) {
                if (WorkProcess != null)
                {
                    throw new InvalidOperationException("This instance of FFmpegProcess is busy. You can run concurrent commands by creating other class instances.");
                }
                P           = factory.Create();
                WorkProcess = P;
            }
            output.Clear();
            cancelWork = new CancellationTokenSource();
            if (Options == null)
            {
                Options = new ProcessOptions();
            }

            P.StartInfo.FileName  = fileName;
            P.StartInfo.Arguments = arguments;
            CommandWithArgs       = string.Format(@"""{0}"" {1}", fileName, arguments).TrimEnd();

            if (OutputType == ProcessOutput.Output)
            {
                P.OutputDataReceived += OnDataReceived;
            }
            else if (OutputType == ProcessOutput.Error)
            {
                P.ErrorDataReceived += OnDataReceived;
            }

            if (Options.DisplayMode != FFmpegDisplayMode.Native)
            {
                if (Options.DisplayMode == FFmpegDisplayMode.Interface && Config.UserInterfaceManager != null)
                {
                    Config.UserInterfaceManager.Display(this);
                }
                P.StartInfo.CreateNoWindow = true;
                P.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                if (OutputType == ProcessOutput.Output)
                {
                    P.StartInfo.RedirectStandardOutput = true;
                }
                else if (OutputType == ProcessOutput.Error)
                {
                    P.StartInfo.RedirectStandardError = true;
                }
                P.StartInfo.UseShellExecute = false;
            }

            ProcessStarted?.Invoke(this, new ProcessStartedEventArgs(this));

            P.Start();
            try {
                if (!P.HasExited)
                {
                    P.PriorityClass = Options.Priority;
                }
            } catch { }
            if (Options.DisplayMode != FFmpegDisplayMode.Native)
            {
                if (OutputType == ProcessOutput.Output)
                {
                    P.BeginOutputReadLine();
                }
                else if (OutputType == ProcessOutput.Error)
                {
                    P.BeginErrorReadLine();
                }
            }

            bool Timeout = Wait();

            // ExitCode is 0 for normal exit. Different value when closing the console.
            CompletionStatus Result = Timeout ? CompletionStatus.Timeout : cancelWork.IsCancellationRequested ? CompletionStatus.Cancelled : P.ExitCode == 0 ? CompletionStatus.Success : CompletionStatus.Failed;

            cancelWork           = null;
            LastCompletionStatus = Result;
            ProcessCompleted?.Invoke(this, new ProcessCompletedEventArgs(Result));
            if ((Result == CompletionStatus.Failed || Result == CompletionStatus.Timeout) && Options.DisplayMode == FFmpegDisplayMode.ErrorOnly)
            {
                Config.UserInterfaceManager?.DisplayError(this);
            }

            WorkProcess = null;
            return(Result);
        }
Exemplo n.º 15
0
 public Task MarkProcessCompleted(ProcessCompleted message, CancellationToken ct, string bucketId = null)
 {
     return(AppendToStream(message.ProcessId, message, bucketId));
 }
Exemplo n.º 16
0
 protected virtual void OnProcessCompleted()
 {
     Console.WriteLine("Begin completed process!");
     ProcessCompleted?.Invoke();
 }
 protected virtual void OnProcessCompleted()
 {
     ProcessCompleted?.Invoke(); //Hier springt er in die angehängte Methode rein -> Program.cs ->  private static void Pbl_ProcessCompleted()
 }
Exemplo n.º 18
0
 protected virtual void OnPorcessCompleted()
 {
     ProcessCompleted?.Invoke(this, EventArgs.Empty);
 }
 public virtual void OnProcessCompleted()
 {
     ProcessCompleted?.Invoke();
 }
Exemplo n.º 20
0
        /// <summary>
        /// Runs specified process with specified arguments.
        /// </summary>
        /// <param name="fileName">The process to start.</param>
        /// <param name="arguments">The set of arguments to use when starting the process.</param>
        /// <returns>The process completion status.</returns>
        /// <exception cref="System.IO.FileNotFoundException">Occurs when the file to run is not found.</exception>
        /// <exception cref="InvalidOperationException">Occurs when this class instance is already running another process.</exception>
        public virtual CompletionStatus Run(string fileName, string arguments)
        {
            fileName.CheckNotNullOrEmpty(nameof(fileName));

            IProcess p;

            lock (LockToken)
            {
                if (WorkProcess != null)
                {
                    throw new InvalidOperationException(Resources.ProcessWorkerBusy);
                }
                p           = _factory.Create();
                WorkProcess = p;
            }
            _output.Clear();
            _cancelWork = new CancellationTokenSource();
            if (Options == null)
            {
                Options = new ProcessOptions();
            }

            p.StartInfo.FileName  = fileName;
            p.StartInfo.Arguments = arguments;
            CommandWithArgs       = $@"""{fileName}"" {arguments}".TrimEnd();

            if (OutputType == ProcessOutput.Output)
            {
                p.OutputDataReceived += OnDataReceived;
            }
            else if (OutputType == ProcessOutput.Error)
            {
                p.ErrorDataReceived += OnDataReceived;
            }

            if (Options.DisplayMode != ProcessDisplayMode.Native)
            {
                //if (Options.DisplayMode == ProcessDisplayMode.Interface && Config.UserInterfaceManager != null)
                //{
                //    Config.UserInterfaceManager.Display(Owner, this);
                //}

                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                if (OutputType == ProcessOutput.Output)
                {
                    p.StartInfo.RedirectStandardOutput = true;
                }
                else if (OutputType == ProcessOutput.Error)
                {
                    p.StartInfo.RedirectStandardError = true;
                }

                p.StartInfo.UseShellExecute = false;
            }

            ProcessStarted?.Invoke(this, new ProcessStartedEventArgs(this));

            p.Start();
            try
            {
                if (!p.HasExited)
                {
                    p.PriorityClass = Options.Priority;
                }
            }
            catch (System.ComponentModel.Win32Exception) { }
            catch (InvalidOperationException) { }

            if (Options.DisplayMode != ProcessDisplayMode.Native)
            {
                if (OutputType == ProcessOutput.Output)
                {
                    p.BeginOutputReadLine();
                }
                else if (OutputType == ProcessOutput.Error)
                {
                    p.BeginErrorReadLine();
                }
            }

            var timeout = Wait();

            // ExitCode is 0 for normal exit. Different value when closing the console.
            var result = timeout ? CompletionStatus.Timeout : _cancelWork.IsCancellationRequested ? CompletionStatus.Cancelled : p.ExitCode == 0 ? CompletionStatus.Success : CompletionStatus.Failed;

            _cancelWork = null;
            // Allow changing CompletionStatus in ProcessCompleted.
            var completedArgs = new ProcessCompletedEventArgs(result);

            ProcessCompleted?.Invoke(this, completedArgs);
            result = completedArgs.Status;
            LastCompletionStatus = result;
            //if ((result == CompletionStatus.Failed || result == CompletionStatus.Timeout) && Options.DisplayMode == ProcessDisplayMode.ErrorOnly)
            //{
            //    Config.UserInterfaceManager?.DisplayError(Owner, this);
            //}

            WorkProcess = null;
            return(result);
        }
Exemplo n.º 21
0
 protected virtual void OnProcessCompleted(bool IsSuccessful)
 {
     ProcessCompleted?.Invoke(this, IsSuccessful);
 }
 //Denne metode "raises" eventet
 protected virtual void OnProcessCompleted(ProcessEventArgs e)
 {
     //invokes the delegate
     // This will call all the event handler methods registered with the ProcessCompleted event.
     ProcessCompleted?.Invoke(this, e);
 }
Exemplo n.º 23
0
 //protected virtual method
 // Protected and virtual enable derived classes to override the logic for raising the event.
 //However, A derived class should always call the On<EventName> method of the base class to ensure that registered delegates receive the event.
 protected virtual void OnProcessCompleted()
 {
     //if ProcessCompleted is not null then call delegate
     ProcessCompleted?.Invoke(EnteredValue);
 }
Exemplo n.º 24
0
 protected virtual void OnProcessCompleted() //protected virtual method
 {
     //if ProcessCompleted is not null then call delegate
     ProcessCompleted?.Invoke();
 }
Exemplo n.º 25
0
 protected virtual void OnProcessCompleted() //protected virtual method
 {
     ProcessCompleted?.Invoke();
 }
Exemplo n.º 26
0
 private void Apply <TEvent>(ProcessCompleted <TEvent> @event)
 {
     State = InstanceStates.Completed;
 }
 public virtual void OnProcessCompleted(EventArgs e)
 {
     ProcessCompleted?.Invoke(this, e);
 }
Exemplo n.º 28
0
 protected virtual void OnProcessCompleted()
 {
     Console.WriteLine("Hello");
     ProcessCompleted?.Invoke();
 }
Exemplo n.º 29
0
 protected virtual void OnProcessCompleted()
 {
     // if ProcessCompleted is not null then call delegate
     // this will call all the event handler methods registered with the ProcessCompleted event.
     ProcessCompleted?.Invoke();
 }
Exemplo n.º 30
0
 protected virtual void OnProcessCompleted(ProcessEventArgs e)
 {
     ProcessCompleted?.Invoke(this, e);
 }