0
我读样品希洛由微软提供,ImageBrowserViewModel.cpp下有一些代码,我不明白:线程在Windows商店应用
// Observe the update after waiting the specified amount of time.
create_task([timeToWait]() {
assert(IsBackgroundThread());
::wait(timeToWait);
}).then([weakThis]() {
assert(IsMainThread());
auto vm = weakThis.Resolve<ImageBrowserViewModel>();
if (nullptr != vm)
{
vm->ObserveFileChange();
vm->m_hasFileUpdateTask = false;
}
}, task_continuation_context::use_current()).then(ObserveException<void>(m_exceptionPolicy));
的追求是使用应用IsBackgroundThread()
& IsMainThread()
断言它应该是在特定环境下正确调用。但对于::wait(timeToWait)
函数调用,没有task_continuation_context
定义来确保它在后台运行,我只是想知道它是如何工作的?非常感谢!