タスクを使った非同期処理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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