Hello Folks
I’m pretty new in C# and Gadgeteer… but I make my way bit by bit.
Actually I have a small issue with c# itself… it’s probably cuz of some missing knowledge about it^^
I’m not sure if that is the correct section for this… althought is more a basic C# issue, I post it here… since you probably better understand what I wanna do^^
I just know it from Java… is the Main Methode is through tha program will stop. in C# is that not the case… althought there is no actual code to process through… it doesn’t stop and it reacts to events like the button.
So I thought it always repeats the main methode in C#… but that’s also not the case, cuz then it would print me all the time “Program Sstarted” from the Debug.Print.
In Java would there be a stupid but effective solution… you wrap all into a DO{}While(True) loop and let the program run forever.
C# seems not very pleased with that… depens on where i place that infinity loop, i get memory overflow. but sometimes it works.
I tried also to cancel that loop with a simple boolean that can end the loop by pressing a button… the thing is, if the button event is inside that loop… it won’t let me call a methode outside that would set the loop-boolean on false to end the loop.
same issue i got with IF cases… even thought the IF condition is true, the program won’t go in since it’s not repeating the main methode all the time.
I made some tests with the Joystick… i wanna have the joystick always active… and not checking the IF condition when I press a button or something. it did wotk if i wrapped it inside a DO-While-True loop… but ah well… you know…
How you ppl solve that issue? >.<
This I’d like to have inside the main methode… but it only goey onetime through if i don’t wrap a loop around it >.<
JoystickPosX = joystick.GetJoystickPosition().X;
Debug.Print("X: " + JoystickPosX);
JoystickPosY = joystick.GetJoystickPosition().Y;
Debug.Print("Y: " + JoystickPosY);
if ((JoystickPosY < 0.25) && (Flip1 == 0))
{
Debug.Print("LED nach R");
Debug.Print("Flip1:" + Flip1);
Flip1 = 1;
Led++;
led7r.TurnLightOn(Led, true);
}
if ((JoystickPosY > 0.25) && (JoystickPosY < 0.75))
{
Flip1 = 0;
}
if ((JoystickPosY > 0.75) && (Flip2 == 0))
{
Debug.Print("LED nach L");
Debug.Print("Flip2:" + Flip2);
Flip2 = 1;
Led = Led - 1;
led7r.TurnLightOn(Led, true);
}
if ((JoystickPosY > 0.25) && (JoystickPosY < 0.75))
{
Flip2 = 0;
}