As far as I'm concerned, it's not supported for C++/WinRT to enable passing functions with parameters. You can also use a Lambda function to wrap these functions except std::bind
.
WinUI3 : How to use DispatcherQueue without Lambda function to exec a parameterized function
Hi,
Im working on a WinUI3 desktop application in CPP without using XAML files.
In my application, I'm using the Dispatcher queue to switch from the worker thread to the main thread.
int winid = 1;
DispatcherQueueHandler executeinstructiondispatch = [=] () { TWOSInstructionHandler::ExecuteInstructionSet (winid);
}
TWWinUI3App::sDispatcherQueue.TryEnqueue (executeinstructiondispatchhandler);
Here to execute a parameterized function in the main thread, Im using the Lambda function.
For some reason, I do not want to use any Lambda functions in my application. Is there any way to make this peace of code work without the Lambda function?
I could have done this if it was not a parameterized function,
DispatcherQueueHandler executeinstructiondispatch = TWOSInstructionHandler::ExecuteInstructionSet;
In the case of a parameterized function, is there a way to use Dispatcher Queue without the lambda function?
Thank you
-
Xiaopo Yang - MSFT 12,151 Reputation points Microsoft Vendor
2023-11-28T08:14:04.2833333+00:00