|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multitasking
After a good hour or so of reading through documentations and any other related page I could find, creating new tasks has me stumped. I'm not sure exactly where to put the line of code the documentation shows as an example, or where to point the function to (do I just leave it as FUNCPTR?).
Code:
Task myTask("taskname", (FUNCPTR) functionToStart)
Jacque |
|
#2
|
||||
|
||||
|
Re: Multitasking
The most common way of implementing a new task is using a static void in an object's class. The compressor class uses a task to monitor the air flow, etc. If you want to write a task, you can take a look at the .cpp of the compressor class. Here is some sample code too.
This is a sample header file. Code:
class Sample {
public:
//constructor, other functions
private:
Task task;
static void TaskRunner(Sample *s);
};
Code:
Sample::Sample() :
task("Sample Task", (FUNCPTR) TaskRunner)
{
task.Start((INT32)this);
}
void Sample::TaskRunner(Sample *s) {
//Task code here
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|