Ejemplo n.º 1
0
 public static void RaiseLongTaskEvent(object sender, LongTaskEventArgs args)
 {
     LongTaskEvent(sender, args);
     DoEvents();
 }
Ejemplo n.º 2
0
        void LongTaskExecutor_LongTaskEvent(object sender, LongTaskEventArgs args)
        {
            switch (args.Status)
            {
                case TaskStatus.Started:
                    this.Cursor = WaitingCursor;
                    if (progressWnd == null)
                    {
                        progressWnd = new LongTaskProgressWindow();
                    }
                    else
                    {
                        progressWnd.Reference++;
                    }

                    this.grdMain.IsEnabled = false;
                    progressWnd.ProgressMessage = args.TaskName + " - start";
                    progressWnd.Owner = this;
                    progressWnd.Show();
                    
                    break;
                case TaskStatus.Finished:
                    if (progressWnd != null)
                    {
                        progressWnd.Reference--;
                    }

                    if (progressWnd != null)
                    {
                        progressWnd.ProgressMessage = args.TaskName + " - end";
                        if (progressWnd.Reference == 0)
                        {
                            progressWnd.Close();
                            progressWnd.Owner = null;
                            progressWnd = null;

                            this.Activate();
                            this.grdMain.IsEnabled = true;
                        }
                        this.Cursor = NormalCursor;
                    }
                    break;
                case TaskStatus.InProgress:
                    if (progressWnd != null)
                    {
                        progressWnd.ProgressMessage = args.ProgressMessage;
                    }

                    break;
            }
        }