我正在制作一个简单的应用程序,它使用 http get 请求将位置数据发送到服务器。问题是尽管请求位于 positionchanged 事件处理程序中,但该请求仅在第一次发出。
这是我的代码。我找不到它有什么问题。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Device.Location;
namespace kechap
{
public partial class MainPage : PhoneApplicationPage
{
GeoCoordinateWatcher gw = new GeoCoordinateWatcher();
Uri url = new Uri("http://127.0.0.1:5000/upload/1e3fae069dd62fa1641183cd77092ed2053a0e75/1/2");
// Constructor
public MainPage()
{
InitializeComponent();
gw.MovementThreshold = 10;
gw.PositionChanged += (s, e) =>
{
MyMap.Center = e.Position.Location;
MyPushpin.Location = e.Position.Location;
WebClient wc = new WebClient();
wc.OpenReadAsync(url);
wc.OpenReadCompleted += (ss, ee) =>
{
};
};
gw.Start();
}
}
}