Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.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
在执行另一个函数后调用计时器函数-UWP C#_C#_Timer_Uwp_Dispatchertimer - Fatal编程技术网

在执行另一个函数后调用计时器函数-UWP C#

在执行另一个函数后调用计时器函数-UWP C#,c#,timer,uwp,dispatchertimer,C#,Timer,Uwp,Dispatchertimer,我只想在执行函数PreCalculateAsync()后调用计时器函数。现在计时器每30毫秒调用一次。但最初我想执行precalculatesync函数。我怎样才能做到这一点 我的代码: public PathAnimation(Geopath path, IntervalCallback intervalCallback, bool isGeodesic, int? duration) { PreCalculateAsync(); _timerId

我只想在执行函数PreCalculateAsync()后调用计时器函数。现在计时器每30毫秒调用一次。但最初我想执行precalculatesync函数。我怎样才能做到这一点

我的代码:

 public PathAnimation(Geopath path, IntervalCallback intervalCallback, bool isGeodesic, int? duration)
    {
        PreCalculateAsync(); 
        _timerId = new DispatcherTimer();
        _timerId.Interval = new TimeSpan(0, 0, 0, 0, 30);

        _timerId.Tick += (s, a) =>
        {
            if (!_isPaused)
            {
                if (intervalCallback != null)
                {
                    intervalCallback(_intervalLocs[_frameIdx], _intervalIdx[_frameIdx], _frameIdx);
                }

                if (_frameIdx + 1 == _intervalLocs.Count())
                {
                    _timerId.Stop();
                }                 
                _frameIdx++;

            }
        };
    }

    public delegate void IntervalCallback(BasicGeoposition loc, int pathIdx, int frameIdx);
    private async void PreCalculateAsync()
    {
        if (_timerId != null && _timerId.IsEnabled)
        {
            _timerId.Stop();
        }
       //assign values to _intervalLocs here. 
     } 
   }

尝试使用
await
关键字等待对
precalculatesync
的调用。也许可以使用
情节提要来定义动画。在启动计时器之前调用precalculatesync?你真正的问题是什么?