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


C# Timers.Timer类代码示例

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


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

示例1: UpdateHeartbeat

        public void UpdateHeartbeat()
        {
            // Create or Update External XML For Last Update Check DateTime
            if (!File.Exists(CheckUpdateFile))
            {
                DateTime DateTimeNow = DateTime.Now;
                XmlWriterSettings wSettings = new XmlWriterSettings();
                wSettings.Indent = true;
                XmlWriter writer = XmlWriter.Create(CheckUpdateFile, wSettings);
                writer.WriteStartDocument();
                writer.WriteComment("This file is generated by WWIV5TelnetServer - DO NOT MODIFY.");
                writer.WriteStartElement("WWIV5UpdateStamp");
                writer.WriteStartElement("LastChecked");
                writer.WriteElementString("DateTime", DateTimeNow.ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }

            // Do Update Check
            updateTimer = new System.Timers.Timer(1000 * 60 * 60); // Hourly - Release Code
            //updateTimer = new System.Timers.Timer(1000 * 10); // 10 Seconds for Testing Only
            updateTimer.Elapsed += new ElapsedEventHandler(DoUpdateCheck);
            updateTimer.AutoReset = true;
            updateTimer.Enabled = true;
            if (Properties.Settings.Default.checkUpdates == "On Startup")
            {
                DoUpdateCheck(null, null);
            }
        }
开发者ID:firefighter389,项目名称:wwiv,代码行数:32,代码来源:CheckUpdates.cs

示例2: StartTimer

 /// <summary>
 /// Start timer function
 /// </summary>
 private void StartTimer()
 {
     timer = new Timer(TimerInterval);
     timer.Elapsed += new ElapsedEventHandler(TimerEvent);
     timer.AutoReset = true;
     timer.Enabled = true;
 }
开发者ID:chartly,项目名称:flood,代码行数:10,代码来源:ProjectManager.cs

示例3: InitializeImpl

 protected override void InitializeImpl()
 {
     this._timers = this.TimerJobs
         .Where(j => j.Item1 > 0.0)
         .OrderBy(j => j.Item1)
         .Select(j =>
         {
             Timer timer = new Timer(j.Item1);
             timer.Elapsed += (sender, e) =>
             {
                 timer.Stop();
                 try
                 {
                     this.Host.RequestManager.Execute<Object>(Request.Parse(j.Item2));
                 }
                 finally
                 {
                     timer.Start();
                 }
             };
             return timer;
         }).ToList();
     this.RunInitializingJobs();
     base.InitializeImpl();
 }
开发者ID:takeshik,项目名称:metatweet-old,代码行数:25,代码来源:LocalServant.cs

示例4: HomeViewModel

 public HomeViewModel()
 {
     timer = new Timer(1000);
     timer.Elapsed += TimerElapsed;
     timer.AutoReset = true;
     timer.Start();
 }
开发者ID:blounty,项目名称:mvvm-helpers,代码行数:7,代码来源:HomeViewModel.cs

示例5: SamplingTargetPointGenerator

 public SamplingTargetPointGenerator(int samplesPerSecond)
 {
     workerTimer = new Timer(1000 / samplesPerSecond);
     workerTimer.Elapsed += this.WorkerTimerElapsed;
     workerTimer.AutoReset = false;
     workerTimer.Start();
 }
开发者ID:jongeorge1,项目名称:Kinect-Playground,代码行数:7,代码来源:SamplingTargetPointGenerator.cs

示例6: Server

 public Server()
 {
     config = new INIReader(System.IO.File.ReadAllLines("config.ini"));
     chat = new ServerChat();
     instance = this;
     vehicleController = new ServerVehicleController();
     api = new ServerApi(this);
     gamemodeManager = new GamemodeManager(api);
     gamemodeManager.loadFromFile("gamemodes/" + config.getString("gamemode"));
     server = new TcpListener(IPAddress.Any, config.getInt("game_port"));
     server.Start();
     server.BeginAcceptTcpClient(onIncomingConnection, null);
     playerpool = new List<ServerPlayer>();
     Timer timer = new Timer();
     timer.Elapsed += onBroadcastTimer;
     timer.Interval = config.getInt("broadcast_interval");
     timer.Enabled = true;
     timer.Start();
     UDPStartPort = config.getInt("udp_start_port");
     Timer timer_slow = new Timer();
     timer_slow.Elapsed += timer_slow_Elapsed;
     timer_slow.Interval = config.getInt("slow_interval");
     timer_slow.Enabled = true;
     timer_slow.Start();
     http_server = new HTTPServer();
     Console.WriteLine("Started game server on port " + config.getInt("game_port").ToString());
     Console.WriteLine("Started http server on port " + config.getInt("http_port").ToString());
 }
开发者ID:andrefsantos,项目名称:gta-iv-multiplayer,代码行数:28,代码来源:Server.cs

示例7: Run

		protected override void Run ()
		{
			if (!Taskbar.TaskbarManager.IsPlatformSupported) {
				return;
			}
			
			bool areFileExtensionsRegistered = this.Initialize ();
			
			if (!areFileExtensionsRegistered) {
				return;
			}
			
			this.updateTimer = new Timer (1000);
			this.updateTimer.Elapsed += this.OnUpdateTimerEllapsed;
			this.updateTimer.AutoReset = false;
			
			this.recentFiles = DesktopService.RecentFiles;
			this.recentFiles.Changed += this.OnRecentFilesChanged;

			try {
				UpdateJumpList();
			} catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Could not update jumplists", ex);
			}
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:25,代码来源:JumpList.cs

示例8: ExchangesWindow

        public ExchangesWindow()
        {
            InitializeComponent();
            DataContext = this;

            Exchanges = new ObservableCollection<Exchange>();

            List<Exchange> tmpExchanges;
            using (var entityContext = new MyDBContext())
            {
                tmpExchanges = entityContext.Exchanges.Include("Sessions").OrderBy(x => x.Name).ToList();
            }
            foreach (Exchange e in tmpExchanges)
            {
                Exchanges.Add(e);
            }

            ExchangesGrid.ItemsSource = Exchanges;

            _filterTimer = new Timer();
            _filterTimer.Enabled = false;
            _filterTimer.AutoReset = false;
            _filterTimer.Interval = 100; //milliseconds
            _filterTimer.Elapsed += _filterTimer_Elapsed;
        }
开发者ID:QANTau,项目名称:QDMS,代码行数:25,代码来源:ExchangesWindow.xaml.cs

示例9: ServerLog

 /// <summary>
 /// Creates a new Instance of the ServerLog
 /// </summary>
 public ServerLog()
 {
     _buffer = new StringBuilder(4096);
     _writetimer = new Timer();
     _writetimer.Interval = 5000;
     _writetimer.Elapsed += _writetimer_Elapsed;
 }
开发者ID:webmaster442,项目名称:EmbeddedHttpServer,代码行数:10,代码来源:ServerLog.cs

示例10: MainWindow

 public MainWindow()
 {
     InitializeComponent();
     _timer = new Timer(30000);
     _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
     _timer.Enabled = true;
 }
开发者ID:xHeinrich,项目名称:keeperScoreboard,代码行数:7,代码来源:MainWindow.xaml.cs

示例11: Ux2CampaignService

        public Ux2CampaignService()
        {
            InitializeComponent();
            //this.cExcHandler = new GanoExceptionHandling(EXC_URL, cErrorFile);

            LoadSettings();

            if (!EventLog.SourceExists(EVENT_LOG_SOURCE))
                EventLog.CreateEventSource(EVENT_LOG_SOURCE, EVENT_LOG);

            try
            {
                this.cScheduleTimer = new System.Timers.Timer(this.cInterval);
                this.cScheduleTimer.Elapsed += new ElapsedEventHandler(cScheduleTimer_Elapsed);
                this.cScheduleTimer.Enabled = true;

                EventLog.WriteEntry(EVENT_LOG_SOURCE, "Ux2 Campaign Service Started on " + DateTime.Now.ToString() + "\n" +
                    "Settings loaded from " + Path.GetDirectoryName(Application.ExecutablePath) + "\\" + SETTINGS_FILE + "\n" +
                    "Processing Interval: " + this.cInterval + "ms\n" +
                    "Max Campaign Age: " + this.cMaxAge + "hours");

                this.cProcessor = new ScheduleProcessor(this.cConnectionString, cMaxAge);
                this.cProcessorCaller = new CallScheduleProcessor(this.cProcessor.ProcessSchedules);
            }
            catch (Exception exc)
            {
                //this.cExcHandler.LogExceptionQuiet(null, exc);
                EventLog.WriteEntry(EVENT_LOG_SOURCE, exc.Message);
            }
        }
开发者ID:vm-aorcasitas,项目名称:C8-Ux2CampaignSystem,代码行数:30,代码来源:Ux2CampaignService.cs

示例12: CreateMainLoopTimer

 public Object CreateMainLoopTimer(MainServerLoop mainLoop, uint period)
 {
     myTimer = new Timer(period);
     myTimer.Elapsed += (sender, e) => {mainLoop();};
     myTimer.Enabled = true;
     return myTimer;
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:7,代码来源:TimerMainLoopTimer.cs

示例13: btnStart_Click

        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            this.txtID.Text = string.Empty;
            this.txtName.Text = string.Empty;
            this.LblResult.Text = string.Empty;

            try
            {
                Init();
                int interval = 20;
                timer = new Timer();
                timer.Interval = interval;
                timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
                timer.AutoReset = true;
                timer.Enabled = true;
                timer.Start();

                this.btnStart.IsEnabled = false;
                this.btnStop.IsEnabled = true;
                this.btnStop.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
开发者ID:ChegnduJackli,项目名称:Projects,代码行数:26,代码来源:MainWindow.xaml.cs

示例14: RxTimerStage

 /// <summary>Constructs a Rx timer stage</summary>
 /// <param name="observer">the observer</param>
 /// <param name="initialDelay">the initial delay in milli-seconds</param>
 /// <param name="period">the period in milli-seconds</param>
 public RxTimerStage(IObserver<PeriodicEvent> observer, long initialDelay, long period)
 {
     _observer = observer;
     _timer = new Timer(period);
     _timer.Elapsed += (sender, e) => OnTimedEvent(sender, e, _observer, _value);
     _timer.Enabled = true;
 }
开发者ID:beomyeol,项目名称:reef,代码行数:11,代码来源:RxTimerStage.cs

示例15: Server

        /// <summary>
        /// Create an new Instance of the TCP-Listener on Port 5000
        /// </summary>
        internal Server()
        {
            try
            {
                AnrlDB.AnrlDataContext db = new AnrlDB.AnrlDataContext();
                if (!db.DatabaseExists())
                {
                    db.CreateDatabase();
                }

                CalculateTabels = new System.Timers.Timer(20000);
                CalculateTabels.Elapsed += new ElapsedEventHandler(CalculateTabels_Elapsed);
                CalculateTabels.Start();

                running = true;
                this.tcpListener = new TcpListener(IPAddress.Any, 5000);
                this.listenThread = new Thread(new ThreadStart(ListenForClients));
                this.listenThread.Start();
                db.Dispose();
            }
            catch (Exception ex)
            {
                Logger.Log("Exception in Server.Server" + ex.ToString(), 11);
            }
        }
开发者ID:helios57,项目名称:anrl,代码行数:28,代码来源:Reciever.cs


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