gpt4 book ai didi

c# - Xamarin.forms 在 windows8 模拟器中给出 "invalid cross thread access"异常

转载 作者:行者123 更新时间:2023-11-30 22:02:10 25 4
gpt4 key购买 nike

Xamarin.forms 在 android 手机上运行良好,但在 window8 模拟器中它不加载图像并给出无效的跨线程访问异常。

我正在使用 Embedded Image技术,我将所有图像存储在公共(public)文件夹中并从共享项目访问。

我的项目截图如下:

enter image description here

错误如下:

enter image description here

在 window8 模拟器中图像未加载

enter image description here

任何帮助将不胜感激。

最佳答案

这是因为您正在非 UI 线程上更新 UI 元素,您想要使用 Device.BeginInvokeOnMainThread,如下所示:

Device.BeginInvokeOnMainThread(() => MainPage.DisplayAlert("Boom", message, "Cancel"));

关于c# - Xamarin.forms 在 windows8 模拟器中给出 "invalid cross thread access"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27156802/

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