I'm trying to create a Simple Computer simulator in C#. Its been going well up until ive reached a point where i need to have actions performed step by step when a button is clicked.
A little background:
The simple computer is a simulator that helps show students how lower level languages interpret commands.
In the program:
I have 99 Text boxes representing memory cells, 99 Text boxes representing input cards, 99 Text boxes representing output cards, a text box representing the accumulator (basic arithmatic portion of the simple computer), a text box representing the Instruction Register, a text box representing the Program Counter, a button that manually steps through the program entered in to the memory cells, and a button that should step through automatically.
problem:
Basically, my problem is that i need to perform the same action a
number of times and have the GUI update so you can see the actions take
place step by step. This must be done automatically after the button is pressed. I already have a step button programmed well. Is there any way to do this
Thanks in advance.

Simple Computer
Xzarian
Bluehunter
You are doing your processing on the applications GUI thread. The GUI gets no chance to update itself while you are processing the loop.
You should look into threading etc, but for now you should be able to force the GUI to update by calling Control.Refresh() either on the form object or per control, inside your loop.
....
if(c.getOp() == 9)
{
PC.Text = c.getMemCell().ToString();
IR.Text = memoryCells.Text;
j = false;
PC.Refresh();
IR.Refresh();
}
...
Saurabh Kulkarni
example(actual code that doesnt work):
int i;
Checker c = new Checker();
Boolean j = true;
while (j)
{
i = int.Parse(PC.Text);
c.opCode(memoryCells
if(c.getOp() == 9)
{
PC.Text = c.getMemCell().ToString();
IR.Text = memoryCells
j = false;
}
if (!j)
break;
//this.MyEvent += new System.EventHandler(this.Start_Go);
//myEvent(sender, e);
//Step.PerformClick();
//Step_Click(Step, e);
switch (stepSpeed)
{
case 1:
Thread.Sleep(5);
break;
case 2:
Thread.Sleep(4);
break;
case 3:
Thread.Sleep(3);
break;
case 4:
Thread.Sleep(2);
break;
case 5:
Thread.Sleep(1);
break;
}
CoreyMc
Keithyboy1
I've tried that, the problem is im unable to see each event take place. It just shows the end result. Im trying to find a ways to show each step separately, but done automatically.
thanks for the help:).
JosB
Example:
while( moreStepsToExecute ) {
StepButton_Click( StepButton , EventArgs.e );
}