I am working in VCS and am trying to do some simple multitasking for my motor. I am working in C++ Pro and have defined a function of bool frontLeftRotateTo(int speed, int distance). When I try to create a task for this function vex::task(frontLeftRotateTo(50, 1000)). It returns an error saying no know conversions for vex::task. I have tried using the same approach with vex::thread but it returns a similar issue. After some research of cpp libraries, I found the std::thread class. When I try using std::thread it says that thread can’t be found or did you mean vex::thread. I know that this is most likely a syntax issue so any examples of how to start a task or thread of a function that has parameters.
Thanks for any help,
1069B - Argonauts
std::thread is not (and cannot be) supported by VCS.
both vex::task and vex::thread take a function as the parameter, so you would use like this.
using namespace vex;
brain Brain;
int myOtherThread() {
// do something here;
return(0);
}
int main() {
vex::thread myThread = vex::thread( myOtherThread );
while(1) {
// Allow other tasks to run
this_thread::sleep_for(10);
}
}
2 Likes