Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 如何在for循环中添加调度程序计时器?_Windows Phone 7 - Fatal编程技术网

Windows phone 7 如何在for循环中添加调度程序计时器?

Windows phone 7 如何在for循环中添加调度程序计时器?,windows-phone-7,Windows Phone 7,我必须在循环中添加调度程序计时器。我有多个图钉按钮,在运行时我希望在某个时间间隔内检索此图钉按钮,因此如何在循环中添加调度程序计时器 我的C代码是 for (int i = 0; i <= ClsGetDeviceMap.lstLongLatitude.Count - 1; i++) { string lat, lon; lat = ClsGetDevi

我必须在循环中添加调度程序计时器。我有多个图钉按钮,在运行时我希望在某个时间间隔内检索此图钉按钮,因此如何在循环中添加调度程序计时器

我的C代码是

 for (int i = 0; i <= ClsGetDeviceMap.lstLongLatitude.Count - 1; i++)
                    {
                        string lat, lon;
                        lat = ClsGetDeviceMap.lstLatitude.ElementAt<string>(i).Trim();
                        lon = ClsGetDeviceMap.lstLongLatitude.ElementAt<string>(i).Trim();
                        Latitude = Convert.ToDouble(lat);
                        LongLatitude = Convert.ToDouble(lon);
                        GpsSpeed = 44.21811;

                        map1.Center = new GeoCoordinate(Latitude, LongLatitude, GpsSpeed);
                        map1.ZoomLevel = 17;
                        map1.ZoomBarVisibility = Visibility.Visible;


                        pin[i] = new Pushpin();
                        pin[i].Location = new GeoCoordinate(Latitude, LongLatitude);


                        map1.Children.Add(pin[i]);
                        myCoorditeWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
                        myCoorditeWatcher.MovementThreshold = 20;


                        //DispatcherTimer newTimer = new DispatcherTimer();
                        //newTimer.Interval = TimeSpan.FromSeconds(5);
                        //// newTimer.Tick += map1.Children.Add(pin[i]);
                        //newTimer.Start();








                        var gl = GestureService.GetGestureListener(pin[i]);

                        gl.Hold += new EventHandler<GestureEventArgs>(GestureListener_Hold);
                        gl.Tap += new EventHandler<GestureEventArgs>(GestureListener_Stack_Tap);
                        myCoorditeWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myCoorditeWatcher_PositionChanged);


                    }
                    timer = new DispatcherTimer();
                    timer.Interval = TimeSpan.FromMilliseconds(5000);
                    timer.Tick += new EventHandler(timer_Tick);
                    timer.Start();
            }
newTimer.Tick += () =>
{
    map1.Children.Add(pin[i]);
    // probably you need to stop this timer after one tick
    //newTimer.Stop();
};