且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何等待IAsyncAction?

更新时间:2023-01-18 14:17:16

这是完成任务的神奇解决方案:

This is the magical fix that gets the job done :

void WaitForAsync( IAsyncAction ^A )
{   
    while(A->Status == Windows::Foundation::AsyncStatus::Started)
    {   
        CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);                     
    }

    Windows::Foundation::AsyncStatus S = A->Status; 
}