Exemplo n.º 1
0
 private void Pause(object sender, EventArgs e)
 {
     backgroundWorker1.CancelAsync();
     RunFlag = false;
     state   = SimStateMachine.Paused;
     UpdateButtons();
 }
Exemplo n.º 2
0
 public void ReportError(string err)
 {
     metroSetListBox1.AddItem(err);
     metroSetListBox1.AddItem("Halted!");
     state   = SimStateMachine.Stopped;
     RunFlag = false;
     backgroundWorker1.CancelAsync();
     simulator.isHalted = true;
 }
Exemplo n.º 3
0
 private void Stop(object sender, EventArgs e)
 {
     backgroundWorker1.CancelAsync();
     state   = SimStateMachine.Stopped;
     RunFlag = false;
     index   = 0;
     simulator.Stop(richTextBox1.Lines, richTextBox2.Lines);
     UpdateButtons();
 }
Exemplo n.º 4
0
        private void RunOneStep(object sender, EventArgs e)
        {
            if (backgroundWorker1.IsBusy)
            {
                return;
            }

            if (state == SimStateMachine.Ready || state == SimStateMachine.Finished)
            {
                UpdateSim();
            }
            RunFlag = false;
            state   = SimStateMachine.Running;
            backgroundWorker1.RunWorkerAsync(new Tuple <bool, int, string[]>(RunFlag, index, richTextBox1.Lines));
            UpdateButtons();
        }
Exemplo n.º 5
0
        private void Simulator_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            RunFlag = false;
            state   = SimStateMachine.Paused;
            if (e.Cancelled)
            {
                SendLog("Cancelled");
                return;
            }
            var res = (e.Result as Tuple <int, bool>);

            index = res.Item1;
            if (res.Item2)
            {
                state = SimStateMachine.Finished;
            }
            if (simulator.isHalted)
            {
                Stop(null, null);
                return;
            }
            UpdateButtons();
        }