Skip to content

naddu77/MFC_and_Coroutines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MFC_and_Coroutines

This is an example of applying a C++20 coroutine to MFC CWnd.

The usage example is shown below.

FireAndForget CMFCandCoroutinesDlg::TestCoroutine()
{
	auto print_thread_id{ [this](std::wstring_view msg) {
		std::wstringstream ss;

		ss << std::this_thread::get_id();

		AfxMessageBox(std::format(L"{}\nThread ID: {}\n", msg, ss.str()).c_str());
	} };

	print_thread_id(L"Start a coroutine.");

	co_await ResumeBackground();

	print_thread_id(L"Running in the background for 5 seconds.");

	using namespace std::chrono_literals;

	std::this_thread::sleep_for(5s);

	co_await ResumeMfcForeground(this, WM_USER_COROUTINE);

	print_thread_id(L"End of coroutine.");
}

About

Using C++20 coroutines in MFC.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published