How to migrate this DirectX example to winui3 desktop from UWP. #8071
-
Hello community, I'm trying to port an example code of DirectX from UWP to Desktop APP in C++, but always failure in the porting from UWP/WRL to desktop/Winrt. I searched online but haven't found any example code that is really written in C++/WinRT for WinUI3 desktop APP. also there is not template for using DirectX with C++/Winrt and Winui3 for desktop app (not UWP) Can anyone please provide some examples of using directX and swapchainpanel with C++/Winrt for desktop apps (not for UWP) The error comes from the threadpool function migration. but when I using DispatcherQueueController instead, I always see access violation errors. what's the right way to translate those code for WinUI3 desktop with C++/WinRT?? m_renderLoopController=winrt::Microsoft::UI::Dispatching::DispatcherQueueController::CreateOnDedicatedThread(); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
As I said in your question in the Windows App SDK discussions, the dispatcher queue is NOT a proper replacement for a thread pool. You want to be using the thread pool, either through the ThreadPool runtime class or through the Windows Thread Pool API. |
Beta Was this translation helpful? Give feedback.
-
Thank you @DarranRowe, while I take those part outside the lambda function, it works, so I think it is a lambda lifetime issue here, for the item deviceResource I found a solution: use weak_ptr can sucessfully pass into lambdas. but for the criticalSection variable, and this pointer I haven't found a way yet. I also tried sorry to bother you too much, I'm a chemical process engineer here not a professional programmer, so may lack of some basic knowledge that a professional one should know. I plan to build a software that can draw some simple sketches (similar to VISIO but simple than that) I have tried Win2D but there's some lag/latency on the drawing items when drag & move mentioned in this issue, so I want to check that example I mentioned above (independent thread rendering & independent thread input to reduce the latency) however that example was for UWP. by the way, the Win2D repo seems has been deprecated already. |
Beta Was this translation helpful? Give feedback.
As I said in your question in the Windows App SDK discussions, the dispatcher queue is NOT a proper replacement for a thread pool. You want to be using the thread pool, either through the ThreadPool runtime class or through the Windows Thread Pool API.
I also have to ask at this point, since this is a capturing lambda, have you confirmed that this isn't a lambda lifetime issue? This is a general C++ knowledge issue. The simplest way to test that out would be to make the lambda into a member function.