Creating a task using a non-static class function

yea, you have to use a static member function as a callback for tasks (and threads). However, you can pass the current class instance as a parameter to the callback and use that to do instance specific things. Here’s a simple example.

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       james                                                     */
/*    Created:      Sat Jul 04 2020                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

class foo {
    public:
      vex::thread t;
      int value;
      int loopDelay;
      int count;

      foo( int val, int delay ) : value(val), loopDelay(delay) {
        count = 0;
        t = vex::thread( foo::bar, static_cast<void *>(this) );
      }
      ~foo() {}

      static int bar( void *arg ) {
          if( arg == NULL )
            return 0;

          foo *instance = static_cast<foo *>(arg);

          while(1) {
            printf("this thread %d %d\n", instance->value, instance->count++ );
            this_thread::sleep_for(instance->loopDelay);
          }
          return 0;
      }
};

int main() {
    foo( 23, 1000 );
    foo( 12, 1200 );  
}