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


C# Timer.Start方法代码示例

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


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

示例1: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.

			searchField.Text = string.Empty;

			var keyStrokeTimer = new Timer (500);
			var timeElapsedSinceChanged = true;

			keyStrokeTimer.Start ();

			keyStrokeTimer.Elapsed += (sender, e) => {
				timeElapsedSinceChanged = true;
			};

			var searchText = "";
			searchField.EditingChanged += async (sender, e) => {
				keyStrokeTimer.Stop ();

				if (timeElapsedSinceChanged) {
					// Probably should do some locking
					timeElapsedSinceChanged = false;
					keyStrokeTimer.Stop ();

					if (!string.IsNullOrEmpty (searchField.Text)) {
						if (!searchText.Equals (searchField.Text)) {
							searchText = searchField.Text;

							var results = await SearchCheeses (searchText);

							foreach (var cheeseName in results) {
											Console.WriteLine ($"Cheese name: {cheeseName}");
							}
						}
					}
				}

				keyStrokeTimer.Start();
			};


//			var editing = searchField.Events ().EditingChanged;
//
//			var searchSteam = editing
//				.Select (_ => searchField.Text)
//				.Where (t => !string.IsNullOrEmpty (t))
//				.DistinctUntilChanged ()
//				.Throttle (TimeSpan.FromSeconds (0.5))
//				.SelectMany (t =>
//					SearchCheeses (t));			                  
//
//			searchSteam.Subscribe (
//				r =>
//				r.ForEach(cheeseName =>
//					Console.WriteLine($"Cheese name: {cheeseName}"))			
//			);
		}
开发者ID:codemillmatt,项目名称:Rx-Cure,代码行数:58,代码来源:ViewController.cs

示例2: SetInterval

 public static TimerHandle SetInterval(TimeSpan delay, Action callback)
 {
   var timer = new Timer(delay.TotalMilliseconds);
   timer.Elapsed += (sender, e) =>
     {
       timer.Stop();
       callback();
       timer.Start();
     };
   timer.AutoReset = false;
   timer.Start();
   return new TimerHandle(timer, callback);
 }
开发者ID:joshclark,项目名称:statsd.net,代码行数:13,代码来源:Utility.cs

示例3: Start

        public void Start()
        {
            Database.Initialize(ConnectionString);
            DapperConfig.Initialize();
            DefaultTraceLogInitializer.Initialize(ConnectionString, TraceLogLevel.Trace);
            MarkdownParser.RegisterJsEngineType<V8JsEngine>();

            _logger.Trace(string.Format("WEBJOB Start: Interval = {0} ミリ秒", Interval.ToString("##,###")));

            var service = new SearchService(ConnectionString);
            var status = service.GetServiceStatusAsync().Result;

            if (status == ServiceStatus.IndexNotExists)
            {
                service.RecreateEsIndexAsync().Wait();
            }

            _timer = new Timer
            {
                Interval = Interval
            };

            _timer.Elapsed += Execute;
            _timer.Start();
        }
开发者ID:yuki87,项目名称:Hinata-on-premise,代码行数:25,代码来源:WebJob.cs

示例4: 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

示例5: App

 /// <summary>
 /// Initializes a new instance of the App class.
 /// </summary>
 /// <param name="appSplashScreen">Instance of application splash screen window.</param>
 public App(DemoSplashScreen appSplashScreen)
 {
     this.appSplashScreen = appSplashScreen;
     applicationSplashScreenTimer = new ST.Timer(100);
     applicationSplashScreenTimer.Elapsed += new ST.ElapsedEventHandler(applicationSplashScreenTimer_Elapsed);
     applicationSplashScreenTimer.Start();
 }
开发者ID:jsinh-blog-code,项目名称:WpfAnimatedSplashScreenSample,代码行数:11,代码来源:App.xaml.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: 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

示例8: CreateJoinForm

    /// <summary>
    /// Constructor
    /// </summary>
    public CreateJoinForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        deviceAddress = addressObject;

        //Set up the event handlers
        peer.FindHostResponse += new FindHostResponseEventHandler(FindHostResponseMessage);
        peer.ConnectComplete += new ConnectCompleteEventHandler(ConnectResult);
        peer.AsyncOperationComplete += new AsyncOperationCompleteEventHandler(CancelAsync);

        //Set up our timer
        updateListTimer = new System.Timers.Timer(300); // A 300 ms interval
        updateListTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.UpdateTimer);
        updateListTimer.SynchronizingObject = this;
        updateListTimer.Start();
        //Set up our connect timer
        connectTimer = new System.Timers.Timer(100); // A 100ms interval
        connectTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.ConnectTimer);
        connectTimer.SynchronizingObject = this;
        // Set up our connect event
        connectEvent = new ManualResetEvent(false);
    }
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:31,代码来源:DPlayConnect_JoinForm.cs

示例9: 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

示例10: Start

 public void Start()
 {
     _t = new Timer();
     _t.Elapsed += Ticked;
     _t.Interval = 1000;
     _t.Start();
 }
开发者ID:zhiyix,项目名称:Alarm-Clock,代码行数:7,代码来源:AlarmTimer.cs

示例11: AbsoluteTimerWaitHandle

        public AbsoluteTimerWaitHandle(DateTimeOffset dueTime)
        {
            _dueTime = dueTime;
            _eventWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            SafeWaitHandle = _eventWaitHandle.SafeWaitHandle;

            var dueSpan = (_dueTime - DateTimeOffset.Now);
            var period = new TimeSpan(dueSpan.Ticks / 10);

            if (dueSpan < TimeSpan.Zero)
            {
                _eventWaitHandle.Set();
            }
            else
            {
                _timer = new Timer(period.TotalMilliseconds)
                {
                    AutoReset = false,
                };

                _timer.Elapsed += TimerOnElapsed;

                _timer.Start();
            }
        }
开发者ID:hash,项目名称:trigger.net,代码行数:26,代码来源:PlatformIndependentNative.cs

示例12: Run

        /// <summary>
        /// Basic run through, timer setup for read and data save from G4
        /// </summary>
        /// <param name="options">Parsed command line parameters</param>
        private static void Run(Options options)
        {
            if (!string.IsNullOrEmpty(options.Time))
            {
                HeadingInfo.WriteMessage(string.Format("G4 will be polled every {0} milliseconds", options.Time));
            }

            if (!string.IsNullOrEmpty(options.OutputFile))
            {
                HeadingInfo.WriteMessage(string.Format("Writing G4 data to: {0}", options.OutputFile));
            }
            else
            {
                HeadingInfo.WriteMessage("G4 data could not be written.");
                Console.WriteLine("[...]");
            }

            Timer myTimer = new Timer();
            myTimer.Elapsed += new ElapsedEventHandler((sender, e) => ReadAndSaveEGV(sender, e, options));
            myTimer.Interval = Int32.Parse(options.Time);
            myTimer.Start();

            while (Console.Read() != 'q')
            {
                ;    // do nothing...
            }
        }
开发者ID:hackingtype1,项目名称:cgm-simple-reader,代码行数:31,代码来源:DexcomCommandLine.cs

示例13: Game

        public Game(string mapPath)
        {
            totalPoints = 0;

            totalRounds = 9; //TU ILE MAP MA GRA TRZEBA WPISAC

            typewriter = Constants.getSoundPlayerInstance();
            typewriter.Stop();
            typewriter.SoundLocation = "step.wav";

            isNewLevel = true;

            currentPositionInPauseMenu = 0;

            timerPauseMenu = new Timer(500);
            timerPauseMenu.AutoReset = true;
            timerPauseMenu.Elapsed += (s, e) => pasueMenuTick(e);
            timerPauseMenu.Start();

            heroObject = new Hero();
            boxObject = new Box();
            pointObject = new Point();
            floorObject = new Floor();
            wallObject = new Wall();

            mapNumber = 1;
            writelock = new object();
            initMap(mapPath, true);
        }
开发者ID:zaba37,项目名称:Skokoban_KCK,代码行数:29,代码来源:Game.cs

示例14: CacheUpdater

 public CacheUpdater()
 {
     updater = new Timer(5000);
     updater.AutoReset = true;
     updater.Elapsed += updater_Elapsed;
     updater.Start();
 }
开发者ID:ChrisK91,项目名称:CWSRestart,代码行数:7,代码来源:CacheUpdater.cs

示例15: VisualTimer

 public VisualTimer(double time)
 {
     Interval = TimeLeft = time;
     _checker = new Timer(100);
     _checker.Elapsed += CheckerElapsed;
     _checker.Start();
 }
开发者ID:rxcompile,项目名称:RxQuestGame,代码行数:7,代码来源:VisualTimer.cs


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