當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。