GetGeopositionAsync does not return

后端 未结 10 693
北恋
北恋 2021-01-08 00:13

In my Windows Phone 8 app, I am trying to use GetGeopositionAsync on the main page to display some items based on user location.

Calling GetGeopositionAsync does not

10条回答
  •  礼貌的吻别
    2021-01-08 00:42

    I had some of the same issues above. When I hooked up to the geolocator.StatusChanged event, I noticed that sequence of events was:

    1. StatusChanged -> Initializing
    2. My await call
    3. StatusChanged -> Ready

    So I added a loop before my await call:

      while (geolocator.LocationStatus == PositionStatus.Initializing)
      {
          System.Threading.Thread.Sleep(100);
      }
    

    This is inelegant, but did work.

提交回复
热议问题