【问题标题】:WriteableBitmap inside Windows 10 IBackgroundTaskWindows 10 IBackgroundTask 中的 WriteableBitmap
【发布时间】:2016-01-29 17:39:14
【问题描述】:

我正在尝试从 Windows 10 应用 (UWP) IBackgroundTask 的运行方法中裁剪图像。 为了实现我正在使用 WriteableBitmapEx 但在我尝试实例化一个新对象的那一刻,我得到了异常:

应用程序调用了一个接口,该接口被编组为 不同的线程。 (来自 HRESULT 的异常:0x8001010E (RPC_E_WRONG_THREAD))

我尝试使用一些调度程序,但发生了其他异常。 有什么想法吗?

【问题讨论】:

    标签: windows-10 uwp windows-10-universal


    【解决方案1】:

    WriteableBitmap 是一个 UI 对象,需要 UI 线程,这是后台任务所缺乏的。

    根据您的需要,您可以使用不同的 API 来处理图像(检查 this topic 以获得 BitmapEncoder)或从 XamlRenderingBackgroundTask 派生您的后台任务,这将在 UI 线程中调用其 OnRun 方法。尽管请记住,由于内存限制,建议在 XamlRenderingBackgroundTask 中使用 C++。

    【讨论】:

    • 很高兴我能帮上忙。如果您接受答案,我将不胜感激 :) 谢谢。
    猜你喜欢
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    • 1970-01-01
    • 2013-08-23
    • 2019-05-10
    • 1970-01-01
    相关资源
    最近更新 更多