Windows 10 IoT核心版-视频打开关闭 [英] Windows 10 IoT Core - video open close

查看:133
本文介绍了Windows 10 IoT核心版-视频打开关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在Raspberry Pi 2中运行Windows 10 IoT核心版的项目.通过打开视频触发项目主题传感器. 但我收到以下错误:

I've been working project in Raspberry Pi 2 running Windows 10 IoT Core. Project subject sensor triggering with open a video. But I am getting the following error:

ProjeVol1.exe中发生了'System.Exception'类型的异常,但 没有用用户代码处理

An exception of type 'System.Exception' occurred in ProjeVol1.exe but was not handled in user code

其他信息:该应用程序调用了一个接口 被编组为另一个线程. (来自HRESULT的异常:0x8001010E (RPC_E_WRONG_THREAD))

Additional information: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))

代码:

private void SensorPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
{
    Debug.WriteLine("Sensor Tetiklendi");
    if (args.Edge == GpioPinEdge.FallingEdge)
    {
        Debug.WriteLine("Falling Edge");
        ledPin.Write(GpioPinValue.High);
        VideoAc();

    }
    else if (args.Edge == GpioPinEdge.RisingEdge)
    {
        Debug.WriteLine("Rising Edge");
        ledPin.Write(GpioPinValue.High);

    }
}


public void VideoAc()
{
    video.AutoPlay = true;
    video.Play();
    video.MediaEnded += Video_MediaEnded;
}

推荐答案

很可能,传感器事件来自与UI线程不同的线程,这使框架感到愤怒.

Likely the sensor event comes from a different thread than the UI's one, and that gets the framework angry.

尝试将VideoAc调用包含在调度程序同步中,如本段所述: UWP从Task更新用户界面

Try to enclose the VideoAc call in a dispatcher synchronization as explained in this piece: UWP update UI from Task

await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
    VideoAc();
});

这篇关于Windows 10 IoT核心版-视频打开关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆