トルネード

毛利のメモ書き

UWP VC++ Dispatcher->RunAsync()

Visual Studio 2017 UWP VC++Dispatcher->RunAsync

Dispatcher.RunAsyncはワーカースレッドから提供されたUIスレッドのコールバックをスケジュールし、結果を非同期的に返します。

もっといい方法あるのかと思うんですが、結局【標準のThread】をつかってしまった。

void  cpp_uwp::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    
    std::thread th1{ [this]() {

        std::this_thread::sleep_for(std::chrono::seconds(3));

        Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() 
        {
            TextBox1->Text = "Dispatcher->RunAsync()";
        }));
    } };
    th1.detach();
}