Reputation: 7715
In C++/CLI is there any way to do the following? (I think answer is no because of no Action support?)
public ref class MyClass {
public:
void TaskMethod();
void Start();
}
void MyClass::Start() {
Task^ myTask = Task::Factory->StartNew(??TaskMethod??);
}
Upvotes: 6
Views: 8840
Reputation: 27874
Action is just a delegate, which is fully supported in C++/CLI. (You might be getting it confused with lambdas, which do not have support in C++/CLI.)
Here's the syntax to create a delegate in C++/CLI.
Task^ myTask = Task::Factory->StartNew(gcnew Action(this, &MyClass::TaskMethod));
// For non-static methods, specify the object. ^^^^
// Use the C++-style reference to a class method. ^^^^^^^^^^^^^^^^^^^^
Upvotes: 13