Exemplo n.º 1
0
        private void RunBatchEdit(StringInstructionSet[] sets)
        {
            bool finished = false, displayed = false; // hack cuz DoWork event isn't cleared after completion

            b.DoWork += (sender, e) =>
            {
                if (finished)
                {
                    return;
                }
                // don't bother reporting progress...
                Processor.Process(sets, Items);
                finished = true;
            };

            b.ProgressChanged    += (sender, e) => SetProgressBar(e.ProgressPercentage);
            b.RunWorkerCompleted += (sender, e) =>
            {
                string result = Processor.GetEditorResults(sets);
                if (!displayed)
                {
                    WinFormsUtil.Alert(result);
                }
                displayed = true;
                RTB_Instructions.Enabled = B_Go.Enabled = true;
                SetupProgressBar(0);
            };
            b.RunWorkerAsync();
        }