1 回答

TA貢獻(xiàn)1942條經(jīng)驗(yàn) 獲得超3個(gè)贊
您的async void
非事件處理程序意味著您的即發(fā)即忘調(diào)用將無(wú)法捕獲可能引發(fā)的任何異常。
使用事件處理程序修復(fù)該問(wèn)題
public partial class NewTravelPage : ContentPage {
? ? public NewTravelPage() {
? ? ? ? InitializeComponent();
? ? ? ? appearing += onAppearing;
? ? }
? ? protected override void OnAppearing() {
? ? ? ? appearing(this, EventArgs.Empty);
? ? }
? ? event EventHandler appearing = delegate { };
? ? private async void onAppearing(object sender, EventArgs args) {
? ? ? ? try {
? ? ? ? ? ? var locator = CrossGeolocator.Current;
? ? ? ? ? ? var position = await locator.GetPositionAsync();
- 1 回答
- 0 關(guān)注
- 137 瀏覽
添加回答
舉報(bào)