MissionPlanner.OSDVideo.timer C# (CSharp) Method

timer() public method

public timer ( ) : void
return void
        public void timer()
        {
            Control.CheckForIllegalCrossThreadCalls = false;

            videopos = startlogtime.AddMilliseconds(-startlogtime.Millisecond);
            hud1.SixteenXNine = true;

            while (true)
            {
                try
                {
                    //   GC.Collect();

                    //  long mem = GC.GetTotalMemory(true) / 1024 / 1024;

                    // Console.WriteLine("mem "+mem);
                    System.Threading.Thread.Sleep(20); // 25 fps

                    if (flightdata.Count == 0)
                        break;
                    //  videopos = videopos.AddMilliseconds(1000 / 25);

//                    m_mediaseek = m_FilterGraph as IMediaSeeking;

                    //  m_mediapos.put_CurrentPosition((vidpos - startlogtime).TotalSeconds);


                    //m_mediaseek.SetTimeFormat(TimeFormat.MediaTime);

                    //long poscurrent = 0;
                    //long posend = 0;

//                    m_mediaseek.GetPositions(out poscurrent,out posend);

                    DateTime cstimestamp =
                        videopos.AddSeconds(trackBar1.Value).AddMilliseconds(-(videopos.Millisecond%20));

                    int tb = trackBar1.Value;

                    if (flightdata.ContainsKey(cstimestamp))
                    {
                        cs = flightdata[cstimestamp];
                    }
                    else if (flightdata.ContainsKey(cstimestamp.AddMilliseconds(-20)))
                    {
                        cs = flightdata[cstimestamp.AddMilliseconds(-20)];
                    }
                    else if (flightdata.ContainsKey(cstimestamp.AddMilliseconds(-40)))
                    {
                        cs = flightdata[cstimestamp.AddMilliseconds(-40)];
                    }

                    //  Console.WriteLine("Update CS");

                    Console.WriteLine("log " + cs.datetime);

                    hud1.datetime = cs.datetime;

                    //cs.UpdateCurrentSettings(bindingSource1,true,MainV2.comPort);

                    bindingSource1.DataSource = cs;
                    bindingSource1.ResetBindings(false);
                }
                catch (ThreadAbortException)
                {
                    break;
                }
                catch
                {
                }
            }
        }