2
루프가 별도의 스레드에서 실행해야한다는 사실에도 불구하고 30 초 동안 윈도우 스토어 앱 블록에서 다음 코드를 실행 UI :스레드 풀 작업 항목이 UI 스레드에서 실행되는 이유는 무엇입니까?
int seconds(30);
// Create a thread pool
ComPtr<IThreadPoolStatics> threadPool;
HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(), &threadPool);
//
// Create an asynchronous task and start it
ComPtr<ABI::Windows::Foundation::IAsyncAction> asyncActionPtr;
hr = threadPool->RunAsync(Callback<IWorkItemHandler>(// Line 1
//
// Lambda for task. Loops doing nothing until 30 seconds have passed
[seconds](ABI::Windows::Foundation::IAsyncAction* asyncAction) -> HRESULT {
std::chrono::system_clock::time_point end(std::chrono::system_clock::now() + std::chrono::seconds(seconds)); // Line 3
while (std::chrono::system_clock::now() < end);
return S_OK; // Line 4
}).Get(), &asyncActionPtr);
if (FAILED(hr)) throw std::exception("Cannot start thread"); // Line 2
나는 표시 줄에 중단 점을 설정, 나는 것을 볼 수 있습니다 라인 1은 라인 2, 라인 3, 30 초 라인 4에 도달합니다.이 30 초 동안 Visual Studio의 스레드보기는 모든 중단 점에 대해 동일한 스레드 (SHcore.dll)를 표시합니다. Windows 8 및 Visual Studio 2012를 사용하고 있습니다. 누군가 설명 할 수 있습니까?