private void executor(object o)
        {
            frmProgress fp = (frmProgress)o;

            orchestrator.Execute(fp);
            //CloseFP(fp);
        }
 private void CloseFP(frmProgress fp)
 {
     if (fp.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
     {
         CloseFPDelegate d = new CloseFPDelegate(CloseFP);
         fp.Dispatcher.Invoke(d, new object[] { fp });
     }
     else
     {
         fp.Close();
     }
 }
        private void ExecuteWorkflow(object sender, ExecutedRoutedEventArgs e)
        {
            //MessageBox.Show("test");
            frmProgress fp = new frmProgress();

            fp.Show();
            fp.SetTitle("Execution progress");
            fp.SetStatus("Building execution tree");
            fp.MyProgressBar.Maximum = 2;
            fp.MyProgressBar.Value   = 0;
            try {
                System.Windows.Forms.Application.DoEvents();
                if (this.Children.OfType <DesignerItem>().ToArray <DesignerItem>().Length == 0)
                {
                    fp.edtLog.Text = "No workflow defined";
                    return;
                }
                DesignerItem[] di = this.Children.OfType <DesignerItem>().ToArray <DesignerItem>();
                orchestrator           = new Orchestrator(this.Children.OfType <DesignerItem>().ToArray <DesignerItem>()[0], this.Children.OfType <Connection>().ToArray <Connection>());
                fp.MyProgressBar.Value = 1;
                fp.SetStatus("Executing workflow tree");
                System.Windows.Forms.Application.DoEvents();
                //executie pe thread separat
                Thread t = new Thread(new ParameterizedThreadStart(executor));
                t.Start(fp);
                //final executie thread separat
            } catch (Exception err) {
                fp.edtLog.Text += "Execution error:\r\n" + err.ToString();
            }


            fp.MyProgressBar.Value = 2;
            //Thread.Sleep(1000);
            System.Windows.Forms.Application.DoEvents();
            //fp.Close();
        }