Exception 应用程序调用了为不同线程封送的接口

Exception 应用程序调用了为不同线程封送的接口,exception,Exception,我得到一个例外: 应用程序调用了为不同线程封送的接口 从我的代码: private void Rec_ResultGenerated(SpeechContinuousRecognitionSession sender,SpeechContinuousRecognitionResultGeneratedEventArgs args) { switch (args.Result.Text) { case "switch one":

我得到一个例外:

应用程序调用了为不同线程封送的接口

从我的代码:

private void Rec_ResultGenerated(SpeechContinuousRecognitionSession sender,SpeechContinuousRecognitionResultGeneratedEventArgs args)
    {

        switch (args.Result.Text)
        {
            case "switch one":
                status.text="Room 1 light switched"; //Error here
                break;
            case "switch two":
                status.text="Room 2 light switched"; //Error here
                break;
            default:
                break;
        }
    }

有什么想法吗?

欢迎来到Stack Overflow!请浏览、和部分,了解此网站的工作原理,并帮助您改进当前和将来的问题,这有助于您获得更好的答案。ResultGenerated事件在工作线程上触发。因此,您不能直接更新UI,必须使用Dispatcher.RunAsync()。请详细说明。谢谢您的帮助。