Arms Won't Move

I used a function that @Deicer told me about thread(functionname).detach();. It has solved a lot of tedious driving problems that have come up when practicing. I used it for the arms like so:
if (MasterController.ButtonDown.pressing()) {
thread(CollectPosition).detach();
}
if (MasterController.ButtonLeft.pressing()) {
thread(LiftToLevel1).detach();
}
if (MasterController.ButtonRight.pressing()) {
thread(LiftToLevel2).detach();
}
This only caused my arms to stop moving. My function specifically states to move the arms:

void CollectPosition () {
Brain.Screen.newLine();

Brain.Screen.print("Initializing...");
Brain.Screen.newLine();
task::sleep(100);

Brain.Screen.print("Lifting...");
Brain.Screen.newLine();
BarMotor.rotateTo(45, rotationUnits::deg, true); //move the arms to 45 degrees

Brain.Screen.print("Finalizing...");
Brain.Screen.newLine(); 
}

Here: thread(CollectPosition).detach(); I was trying to make it run along with everything else. This way of doing things has worked for everything else, why won’t it work for my arms?

I feel slightly terrified if your code runs inside while(1) loop, because it will create very unmanageble count of threads when you press buttons. Please, do not do that.

Then CollectPosition thread may hang waiting for rotateTo() to finish.

Please, call rotateTo() with last argument (waitForCompletion) set to false for non-blocking functionality.

@weilin, I tried what you suggested and after removing the while loop (which did not seem logical to me but I tried it anyway), none of my robot functions worked at all. this was because I removed the main execution loop in the program. Changing the waitForCompletion did not work either even after I added the main execution loop back in.

Any one else have any ideas ?

How about you @Martin?

Not really shure , I dont know programming, but I am trying to learn…

ok. I hope you get better at it!

If I understand your intentions correctly, what you really want is not to remove while(1) loop, but stop using threads and switch to macros.

Please, see these macro examples

VEXcode V5 Text Help

Struggling to program macros

where you use rotateTo(…, waitForCompletion=false) as the action.

If you cannot figure out the code on your own, please, describe in all details exactly what your program needs to do and I will write another macro code example.