タスク(とタスク:: then)内のXAMLコントロールにアクセスしようとすると、Metro XAMLアプリは常に例外で停止します。同じコードは、タスクの外で問題なく動作します。私は何の答えも見つけられませんでした - 私は何を逃しましたか?タスク内のXAMLコントロールへの例外アクセス
VS11デバッガレポート:同時実行:: unobserved_task_exception
例外:アプリケーションが別のスレッドにマーシャリングされたインターフェイスと呼ばれます。
ご協力いただきありがとうございます。 2番目のパラメータとして
void MyClass::MyMemberFunction()
{
xamlStoryboard->Stop(); // ok
xamlImage->Source = ref new BitmapImage(); // ok
task<void> atask([this]()
{
xamlStoryboard->Stop(); // exception!
xamlImage->Source = ref new BitmapImage(); //exception!
});
atask.then([this]()
{
xamlStoryboard->Stop(); // exception!
xamlImage->Source = ref new BitmapImage(); //exception!
});
}
我々はtask_continuation_context追加する場合atask.then()継続コードが例外なく実行されます:: use_current() :
atask.then([this]()
{
xamlStoryboard->Stop(); // now ok!
xamlImage->Source = ref new BitmapImage(); // now ok!
}, task_continuation_context::use_current());
例外はありますか? – animaonline
質問が更新されました - VS11デバッガレポート:Concurrency :: unobserved_task_exception – Telestes
あまり言わなかった、内部例外がありますか? – animaonline