Exemplo n.º 1
0
        public static bool Execute(DelegateWithParams functionToExecute, params object[] args)
        {
            LongOpertationExecutor form = new LongOpertationExecutor();

            form.FunctionToExecute = functionToExecute;
            form.Args = args;
            form.backgroundWorker.RunWorkerAsync();
            return(form.ShowDialog() == DialogResult.OK);
        }
Exemplo n.º 2
0
 private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         Thread.Sleep(200);
         if (FunctionToExecute != null)
         {
             if (FunctionToExecute is SimpleDelegate)
             {
                 SimpleDelegate func = FunctionToExecute as SimpleDelegate;
                 func();
             }
             if (FunctionToExecute is DelegateWithParams)
             {
                 DelegateWithParams func = FunctionToExecute as DelegateWithParams;
                 func(Args);
             }
         }
     }
     catch (Exception ex)
     {
         WindowSkin.MessageBox.Show(ex.Message, "Error");
     }
 }