0

I want to call a timer function only after executing a function PreCalculateAsync(). Now timer is calling every 30 milliseconds. But initially I want to execute PreCalculateAsync function. How can I achieve this?

My code :

 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. 
     } 
   }
user2431727
  • 877
  • 2
  • 15
  • 46

0 Answers0