Skip to content

Instantly share code, notes, and snippets.

@Tocchann
Created August 16, 2019 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tocchann/c1034bb09375a0ac67aa57f1e9338659 to your computer and use it in GitHub Desktop.
Save Tocchann/c1034bb09375a0ac67aa57f1e9338659 to your computer and use it in GitHub Desktop.
タスクを使った非同期処理
void CSampleDlg::OnOK()
{
// いろいろ前処理
CProgressDlg dlg; // 非同期処理で対応できるように修正したプログレス表示クラス
auto task = concurrency::create_task( [&]()
{
return CountCharInFile( dlg, m_targetPath, m_numbers );
} ).then( [&]( bool result )
{
dlg.PostMessage( WM_CLOSE );
return result;
} );
dlg.DoModal();
if( task.get() )
{
// 画面更新
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment