当前位置: 首页>>代码示例>>C#>>正文


C# System.Threading.Timer.Change方法代码示例

本文整理汇总了C#中System.Threading.Timer.Change方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Timer.Change方法的具体用法?C# System.Threading.Timer.Change怎么用?C# System.Threading.Timer.Change使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Timer的用法示例。


在下文中一共展示了System.Threading.Timer.Change方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExactIntervalTimer

       public    ExactIntervalTimer(int atHour, int atMin, int atSec)
          {
              tmr1 = new System.Timers.Timer();
           
              tmr=new System.Threading.Timer(tmr_Elapse);
              this.atHour= atHour;
              this.atMin=atMin;
              this.atSec=atSec;
              
              System.DateTime now = System.DateTime.Now;
              if (atHour != -1 && atMin != -1 && atSec != -1)
              {


                  if (now < new System.DateTime(now.Year, now.Month, now.Day, atHour, atMin, atSec))

                      nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, atHour, atMin, atSec);
                  else
                      nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, atHour, atMin, atSec).AddHours(24);

                 
              }
              else if (atHour == -1 && atMin != -1 && atSec != -1)
                  {


                      if (now < new System.DateTime(now.Year, now.Month, now.Day, now.Hour, atMin, atSec))

                          nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, atMin, atSec);
                      else
                          nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, atMin, atSec).AddHours(1);

                    
                  }
                  else if (atHour == -1 && atMin == -1 && atSec != -1)
                  {


                      if (now < new System.DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, atSec))

                          nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, atSec);
                      else
                          nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, atSec).AddMinutes(1);

                   //   tmr.Change(((TimeSpan)(nextInvokeTime - System.DateTime.Now)).Milliseconds, 1000 * 60  );
                  }

                  try
                  {
                      tmr.Change((int)((TimeSpan)(nextInvokeTime - now)).TotalMilliseconds, System.Threading.Timeout.Infinite);
                  }
                  catch (Exception ex)
                  {
                      tmr.Change(1, System.Threading.Timeout.Infinite);
                  }
          
          
            
          }
开发者ID:ufjl0683,项目名称:slSecureAndPD,代码行数:59,代码来源:ExactIntervalTimer.cs

示例2: BoringCommanderLogic

 public BoringCommanderLogic(BoringCommander form)
 {
     _form = form;
     _initBasicState();
     System.Threading.Timer t = new System.Threading.Timer(_updConfig);
     t.Change(50, 50);
 }
开发者ID:podkolzzzin,项目名称:boringCommander,代码行数:7,代码来源:BoringCommanderLogic.cs

示例3: Work

 void Work()
 {
     
     LoadFile();
     timer = new System.Threading.Timer(Output);
     timer.Change(0, 1000);
 }
开发者ID:fargutvest,项目名称:TriedStartUp,代码行数:7,代码来源:Form1.cs

示例4: button2_Click

        //START Button
        private void button2_Click(object sender, EventArgs e)
        {
            System.Threading.Timer timer = new System.Threading.Timer(urlSend);
            timer.Change(0, 600000);

            Console.WriteLine("Press Enter to exit");
            Console.ReadLine();
        }
开发者ID:Youkyungjin,项目名称:Crawler,代码行数:9,代码来源:Form1.cs

示例5: RtkClient

 public RtkClient(string ip,int port)
 {
     this.ip = ip;
        this.port = port;
        new System.Threading.Thread(ConnectionTask).Start();
        tmr = new System.Threading.Timer(TimerCallBack);
        tmr.Change(5000, 0);
 }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:8,代码来源:RtkClient.cs

示例6: R23PowerMeter

 public R23PowerMeter(int erid, string ip, int port)
 {
     this.ip = ip;
     this.port = port;
     this.ERID = erid;
     tmr = new System.Threading.Timer(TmrCallBack);
     tmr.Change(0, 10 * 60 * 1000);
     TmrCallBack(null);
 }
开发者ID:ufjl0683,项目名称:slSecureAndPD,代码行数:9,代码来源:R23PowerMeter.cs

示例7: Timer

        public Timer()
        {
            _enabled = false;
            _frequency = TimeSpan.FromSeconds(1.0 / 100);
            _interrupt = false;

            _timer = new ThreadTimer(o => _interrupt = true);
            _timer.Change(_frequency, _frequency);
        }
开发者ID:Rohansi,项目名称:LoonyVM,代码行数:9,代码来源:Timer.cs

示例8: GameplayForm

        public GameplayForm(UDPClientServerCommons.Client.ClientSide clientSide)
        {
            InitializeComponent();

            System.Threading.TimerCallback tc = new System.Threading.TimerCallback(timerCallback);
            gameLoopTimer = new System.Threading.Timer(tc);
            gameLoopTimer.Change(1000, 1000);

            network = clientSide;
            //gameLoopTimer = new System.Threading.Timer(new System.Threading.TimerCallback(timerCallback), null, 0, 1000);
        }
开发者ID:kensniper,项目名称:castle-butcher,代码行数:11,代码来源:GameplayForm.cs

示例9: TickRoller

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public TickRoller()
        {
            string tickRollingSpan = WebConfigurationManager.AppSettings["TickRollingSpan"];
            TimeSpan span;
            if (!TimeSpan.TryParse(tickRollingSpan, out span))
            {
                span = TimeSpan.FromSeconds(10);
            }

            HostingEnvironment.RegisterObject(this);
            _timer = new System.Threading.Timer(OnTimerElapsed);
            _timer.Change(TimeSpan.Zero, span);
        }
开发者ID:seraphy,项目名称:SeraphyWebToolboxApp,代码行数:16,代码来源:TickRoller.cs

示例10: Form1

        public Form1()
        {
            InitializeComponent();

            _hideAction = new Action(() => Visible = false);
            _showAction = new Action(() =>
                                       {
                                           SetPosition();
                                           Visible = true;
                                       });

            var checkCapsTimer = new Timer(delegate { CheckCaps(); });
            checkCapsTimer.Change(0, 10);
        }
开发者ID:mariozski,项目名称:CapsLockIndicator,代码行数:14,代码来源:Form1.cs

示例11: ETAGReader

        System.Threading.Timer tmr; //= new System.Threading.Timer();

        #endregion Fields

        #region Constructors

        public ETAGReader(string ip, int cmdport )
        {
            this.IP = ip;
            this.CmdPort = cmdport;
               // this.EventPort = eventport;

            init_tcp();
            Console.WriteLine("Set operation mode to active");
            SetOperationModeActive();

            Console.WriteLine("Version:" + GetVersion());
            EventPort = GetEventPort();
            Console.WriteLine("Event port:" + EventPort);
            Console.WriteLine("model:" + GetModel());
            Console.WriteLine("Antenna detect count:"+GetAtennaDetectCount());
            Console.WriteLine("Antenna port count:" + GetAtennaPortCount());
            Console.WriteLine("Error Status:" + GetErrorStatus());

            tmr = new System.Threading.Timer(new System.Threading.TimerCallback(TmrCallback));
            tmr.Change(0, 10000);
        }
开发者ID:ufjl0683,项目名称:rtaVideoStreamer,代码行数:27,代码来源:ETAGReader.cs

示例12: ControllerBase

        public ControllerBase(ControllerConfigBase config,PropertyBag property)
        {
            this.PropertyBag = property;
            this.DeviceType = config.device_type;
            this.ListenPort = config.listen_port;
            this.ControllerID = config.controller_id;
            this.BuildDate = config.build_date;
            this.VersionNo = config.version_no;
            tmrPeriodDataReport = new System.Threading.Timer(new System.Threading.TimerCallback(PeroidDataReportTask));
            this.config = config;
            CreateDevices(config);
            tmrHwStatus = new System.Threading.Timer(new System.Threading.TimerCallback(TmrHwStausTask));
               // tmrHwStatus.Change(0, 1000);
            SetHWStatusTmr();

              //  tmrPeriodDataReport.Change(GetNextTransmitSeconds()*1000,this.PropertyBag.TransmitCycle*60* 1000);
            SetTransmitCycleTmr();
            StartListening(ListenPort);
            OneMinTmr = new System.Threading.Timer(OneMinTask);
            OneMinTmr.Change(GetNextMinDifferentSec()*1000, 60 * 1000);
            this.protocol.Parse(System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "protocol.txt"), false);
            this.PropertyBag.OnHWStatus_Changed += new EventHandler(PropertyBag_OnHWStatus_Changed);
        }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:23,代码来源:ControllerBase.cs

示例13: Application_Launching

        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            if (timer == null)
            {
                timer = new System.Threading.Timer((_) =>
                {
                    this.RootFrame.Dispatcher.BeginInvoke(() =>
                    {
                        if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() && !this.IsNetworkAvailable)
                        {
                            this.IsNetworkAvailable = false;
                            MessageBox.Show(TextosFront.frontMensajeConexionInternet);
                        }
                        else
                        {
                            this.IsNetworkAvailable = true;
                        }
                    });
                });
                timer.Change(0, 5000);
            }

            serviceRequest = new ServiceRequest2();

            Santander.DataAccess.Services.InitializeServices();
            Santander.DataAccess.Jsons.InitializeJsons();
            Santander.View.Views.InitializeViews();
            selectedEstatusTransferencia = null;
            selectedServicio = null;
            SelectedConsultaCuentasRegistradas = null;
        }
开发者ID:jfrausto914,项目名称:FSW,代码行数:33,代码来源:App.xaml.cs

示例14: init_tmr

        static void init_tmr()
        {
            // tmr2min.Elapsed += new System.Timers.ElapsedEventHandler(tmr2min_Elapsed);
               // tmr30Sec.Elapsed += new System.Timers.ElapsedEventHandler(tmr30Sec_Elapsed);
            DateTime nextTime = DateTime.Now.AddMinutes(1).AddSeconds(-DateTime.Now.Second+30);
            tmr1min = new System.Threading.Timer(tmr60Sec_Elapsed);
            tmr1min.Change((int)((TimeSpan)(nextTime - DateTime.Now)).TotalMilliseconds, System.Threading.Timeout.Infinite);
            tmr5min = new System.Threading.Timer(tmr5min_Elapsed);
            nextTime = DateTime.Now.AddMinutes(-DateTime.Now.Minute % 5).AddSeconds(-DateTime.Now.Second+30).AddMinutes(5);
            tmr5min.Change((int)((TimeSpan)(nextTime - DateTime.Now)).TotalMilliseconds, System.Threading.Timeout.Infinite);

            tmr30min.Elapsed += new System.Timers.ElapsedEventHandler(tmr30min_Elapsed);
            tmr1hour.Elapsed += new System.Timers.ElapsedEventHandler(tmr1hour_Elapsed);
            //tmr30Sec_Elapsed(null, null);
            //tmr2min_Elapsed(null, null);
              //  tmr30Sec.Start();
            //tmr2min.Start();
            tmr1hour.Start();
            tmr30min.Start();
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:20,代码来源:Program.cs

示例15: Application_Activated

        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (timer == null)
            {
                timer = new System.Threading.Timer((_) =>
                {
                    this.RootFrame.Dispatcher.BeginInvoke(() =>
                    {
                        if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() && !this.IsNetworkAvailable)
                        {
                            this.IsNetworkAvailable = false;
                            MessageBox.Show(TextosFront.frontMensajeConexionInternet);
                        }
                        else
                        {
                            this.IsNetworkAvailable = true;
                        }
                    });
                });
                timer.Change(0, 5000);
            }

            serviceRequest = new ServiceRequest2();
            Santander.DataAccess.Services.InitializeServices();
            Santander.DataAccess.Jsons.InitializeJsons();
            Santander.View.Views.InitializeViews();
            bool statusLoadCliente = false;
            bool sesionInit = false;

            IsolatedStorageSettings.ApplicationSettings.TryGetValue("Cuentas", out this.Cuentas);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("Tarjetas", out this.Tarjetas);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("TotalCuentas", out this.TotalCuentas);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("FechaActual", out this.fechaActual);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("EstatusToken", out this.EstatusToken);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("EstatusSoftToken", out this.EstatusSoftToken);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("ZonaToken", out TokenManager.ZONA);
            IsolatedStorageSettings.ApplicationSettings.TryGetValue("LastOtp", out TokenManager.lastOtp);


            if (IsolatedStorageSettings.ApplicationSettings.TryGetValue("SesionIniciada", out sesionInit))
                this.SesionIniciada = sesionInit;
            if (this.SesionIniciada)
            {
                if (PhoneApplicationService.Current.State.ContainsKey("loadClienteStatus"))
                {
                    statusLoadCliente = (bool)PhoneApplicationService.Current.State["loadClienteStatus"];
                    if (statusLoadCliente)
                    {
                        clienteLSP = new ClienteLoadSaveP();
                        if (clienteLSP.loadClient())
                        {

                            System.Diagnostics.Debug.WriteLine("cliente cargado");

                            this.cliente.getFechaActual();
                            this.cliente.ClienteLoad = statusLoadCliente;
                        }
                    }
                    this.loadSaveCliente = true;
                }
            }

            this.matrix = Validaciones.cargarCSVResToken();
        }
开发者ID:jfrausto914,项目名称:FSW,代码行数:66,代码来源:App.xaml.cs


注:本文中的System.Threading.Timer.Change方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。