How to wait for an IAsyncAction?

后端 未结 4 2117
深忆病人
深忆病人 2021-01-04 09:06

In Windows Store Apps, C++(C# is similar though), doing something like

IAsyncAction^ Action = CurrentAppSimulator::ReloadSimulatorAsync(proxyFile);
create_ta         


        
4条回答
  •  醉梦人生
    2021-01-04 09:33

    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; 
    }
    

提交回复
热议问题