gpt4 book ai didi

windows-8 - 在后台任务中实例化 WriteableImage

转载 作者:行者123 更新时间:2023-12-01 06:50:56 24 4
gpt4 key购买 nike

我正在编写一个带有动态磁贴的 Windows 8 商店应用程序。每个动态磁贴都是需要每 x 分钟刷新一次的图像。我正在使用带有时间触发器的后台任务来生成我的图像并刷新磁贴。

生成我的图像意味着创建一个新图像并在其上绘制我的东西,但由于某种原因,我在尝试创建 WriteableBitmap 的新实例时遇到异常:

var newImage = new Windows.UI.Xaml.Media.Imaging.WriteableBitmap(10, 10);

或者

var newImage = BitmapFactory.New(10, 10);



抛出这个异常:

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



我有一个印象,这是因为后台任务中没有 UI 线程,但话说回来,为什么 WriteableBitmap 需要一个 UI 线程?

知道如何解决这个问题吗?我将如何在后台任务中实例化 WriteableBitmap?

最佳答案

事实证明,这在 Windows 8 中是不可能的。

它在后续版本的 Win 8.1 和 UWP 中成为可能,通过 XamlBackgroundTask

关于windows-8 - 在后台任务中实例化 WriteableImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13328503/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com