Beispiel #1
0
 private void local_timer_start()
 {
     local_time_timer.Interval = 100;
     local_time_timer.Mode     = MmTimerMode.Periodic;
     local_time_timer.Tick    += new EventHandler(local_timer_handler);
     local_time_timer.Start();
 }
Beispiel #2
0
 private void btnStartSend_Click(object sender, RoutedEventArgs e)
 {
     if (!InitSendParameter())
     {
         return;
     }
     timer.Interval           = sendInterval;
     lastTime                 = DateTime.Now;
     data                     = new byte[sendDataLength];
     data[0]                  = 1;
     data[7]                  = 1;
     data[sendDataLength - 1] = 1;
     data[sendDataLength - 8] = 1;
     try
     {
         sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
         sendSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, TTL);
         IPEndPoint localep = new IPEndPoint(ipSrc, sendPort);
         sendSocket.Bind(localep as EndPoint);
         MulticastOption mo = new MulticastOption(ipDst);
         sendSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mo);
         remoteEP = new IPEndPoint(ipDst, dstPort);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
         return;
     }
     sendTimer.Start();
     timer.Start();
     isSendRunning = true;
 }
Beispiel #3
0
 private void RunTime()
 {
     timer1          = new MmTimer();
     timer1.Mode     = MmTimerMode.Periodic;
     timer1.Interval = 1000 / this.update_rate;
     timer1.Tick    += Timer1_Tick;
     timer1.Start();
 }
Beispiel #4
0
 public bool Open()
 {
     if (!can.open())
     {
         return(false);
     }
     else
     {
         timer.Start();
         return(true);
     }
 }
Beispiel #5
0
        public static void TryInitMMTimer()
        {
            try
            {
                mmTimer          = new MmTimer();
                mmTimer.Interval = 1;
                mmTimer.Tick    += (s, e) =>
                {
                    if (!UpdateByTimer)
                    {
                        UpdateByTimer = true;
                        waitStartEvent.Set();
                    }

                    DateTime now   = DateTime.Now;
                    long     ticks = now.Ticks - _Now.Ticks;
                    if (ticks < 0 && ticks > (-5L * MINITE * 10000))
                    {
                        return; //时间倒退是不允许的
                    }

                    if (CorrectTimeSecs != 0)
                    {
                        now = now.AddSeconds(CorrectTimeSecs);
                    }

                    _Now = now;
                    Thread.VolatileWrite(ref CurrentTicks, now.Ticks / 10000);
                };
                mmTimer.Disposed += (s, e) =>
                {
                    UpdateByTimer = false;
                    if (null != mmTimer)
                    {
                        mmTimer.Stop();
                        mmTimer = null;
                    }
                };

                mmTimer.Start();
                //WaitStart();
            }
            catch (System.Exception ex)
            {
                UpdateByTimer = false;
            }
        }
Beispiel #6
0
 public void Start() => _timer.Start();
Beispiel #7
0
 public void EvtStart()
 {
     _telemetryUpdater.Start();
 }