Exemplo n.º 1
0
        void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Result == null)
            {
                return;
            }

            List <Process> rProcs = (List <Process>)e.Result;

            //check if list of process is sames as the semi-global one (runningProcesses)
            //if diff, update listbox.
            if (!ProcessesForm.SameProcs(rProcs, runningProcesses))
            {
                //update the running processes array
                runningProcesses = rProcs;

                // the worker might be completed as a result of the form window being closed.
                // so, check if the form is disposed before updating the list.
                if (!IsDisposed)
                {
                    UpdateList();
                }
            }
        }
Exemplo n.º 2
0
        void CheckProcess(int percentDone, int unweightedPercent, string extraStatus, ProgressStatus status, Object payload)
        {
            if (IsDisposed)
            {
                return;
            }

            // update bottom status
            if (!string.IsNullOrEmpty(extraStatus) && extraStatus != panelDisplaying.ProgressStatus)
            {
                panelDisplaying.ProgressStatus = extraStatus;
            }

            if (status == ProgressStatus.Success || status == ProgressStatus.Failure)
            {
                installUpdate.Rollback        -= ChangeRollback;
                installUpdate.ProgressChanged -= CheckProcess;
            }

            if (status == ProgressStatus.Success)
            {
                List <FileInfo> files      = null;
                List <Process>  rProcesses = null;

                var objects = payload as object[];
                if (objects != null)
                {
                    files      = (List <FileInfo>)(objects)[0];
                    rProcesses = (List <Process>)(objects)[1];
                }

                if (rProcesses != null) //if there are some processes need closing
                {
                    // remove processes that have exited since last checked
                    for (int i = 0; i < rProcesses.Count; i++)
                    {
                        try
                        {
                            if (rProcesses[i].HasExited)
                            {
                                rProcesses.RemoveAt(i);
                            }
                        }
                        catch { }
                    }

                    // only continue if processes are still running
                    if (rProcesses.Count > 0)
                    {
                        // show myself, make topmost
                        Show();
                        TopMost = true;
                        TopMost = false;

                        // start the close processes form
                        using (ProcessesForm proc = new ProcessesForm(files, rProcesses, clientLang))
                        {
                            if (proc.ShowDialog() == DialogResult.Cancel)
                            {
                                // cancel the update process
                                CancelUpdate(true, false);
                                return;
                            }
                        }
                    }
                }

                // processes closed, continue on
                update.CurrentlyUpdating += 1;
                InstallUpdates(update.CurrentlyUpdating);
            }

            if (status == ProgressStatus.Failure)
            {
                if (isCancelled)
                {
                    Close();
                    return;
                }

                error        = clientLang.GeneralUpdateError;
                errorDetails = ((Exception)payload).Message;

                ShowFrame(Frame.Error);
            }
        }
Exemplo n.º 3
0
        void CheckProcess(int percentDone, int unweightedPercent, string extraStatus, ProgressStatus status, Object payload)
        {
            if (IsDisposed)
                return;

            // update bottom status
            if (!string.IsNullOrEmpty(extraStatus) && extraStatus != panelDisplaying.ProgressStatus)
                panelDisplaying.ProgressStatus = extraStatus;

            if (status == ProgressStatus.Success || status == ProgressStatus.Failure)
            {
                installUpdate.Rollback -= ChangeRollback;
                installUpdate.ProgressChanged -= CheckProcess;
            }

            if (status == ProgressStatus.Success)
            {
                List<FileInfo> files = null;
                List<Process> rProcesses = null;

                var objects = payload as object[];
                if (objects != null)
                {
                    files = (List<FileInfo>)(objects)[0];
                    rProcesses = (List<Process>)(objects)[1];
                }

                if (rProcesses != null) //if there are some processes need closing
                {
                    // remove processes that have exited since last checked
                    for (int i = 0; i < rProcesses.Count; i++)
                    {
                        try
                        {
                            if (rProcesses[i].HasExited)
                                rProcesses.RemoveAt(i);
                        }
                        catch { }
                    }

                    // only continue if processes are still running
                    if (rProcesses.Count > 0)
                    {
                        // show myself, make topmost
                        Show();
                        TopMost = true;
                        TopMost = false;

                        // start the close processes form
                        using (ProcessesForm proc = new ProcessesForm(files, rProcesses, clientLang))
                        {
                            if (proc.ShowDialog() == DialogResult.Cancel)
                            {
                                // cancel the update process
                                CancelUpdate(true, false);
                                return;
                            }
                        }
                    }
                }

                // processes closed, continue on
                update.CurrentlyUpdating += 1;
                InstallUpdates(update.CurrentlyUpdating);
            }

            if (status == ProgressStatus.Failure)
            {
                if (isCancelled)
                {
                    Close();
                    return;
                }

                error = clientLang.GeneralUpdateError;
                errorDetails = ((Exception)payload).Message;

                ShowFrame(Frame.Error);
            }
        }