Parameters in Task

Hey, all. I have a programming question. I have been using tasks for a while now. The way I define them is:

task myTask = task( functionIAmCalling );

My question is, is there any way to call a function that has parameters?

You can pass in a void pointer (which needs to be explicitly cast) as the second argument, but I strongly recommend against it if there is a potential that you’ll create 100 or more tasks over the course of the program running.

task myTask = task(functionIAmCalling, voidPointerToParamIAmReferencing);

If you only need to do it a handful of times then you can probably get away with it. Whay exactly are you trying to do?

When passing in arguments to tasks, they behave differently to normal tasks in that you can only do it about 100 times before you can’t create any tasks at all for the rest of the time the program is running. Those still add up even if they aren’t running concurrently.
I found that out while making a button system that spawned a new task for every button press. After making that system, I can confidently say that is not the best way to make a button system. I have since rewritten the system in PROS and only use tasks for macros, but it’s definitely still overcomplicated.