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


C# System.Timers.Timer.Start方法代码示例

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


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

示例1: Application_Start

        void Application_Start(object sender, EventArgs e)
        {
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var cancellationToken = new CancellationToken();
            var scheduledTaskDeamon = new Task(token =>
            {
                var taskList = new IPeriodicTask[]
                {
                    new SendEmailPeriodicTask(),
                    new CheckDatabasePeriodicTask()
                };
                foreach (var scheduledTask in taskList)
                {
                    var timer = new System.Timers.Timer(scheduledTask.RunInterval);
                    timer.Elapsed += (o, args) =>
                    {
                        scheduledTask.TaskStart();
                        timer.Start();
                    };
                    timer.AutoReset = false;
                    timer.Start();
                }
            }, cancellationToken);
            scheduledTaskDeamon.Start();
        }
开发者ID:cloveryang,项目名称:AspNetRunPeriodicTask,代码行数:27,代码来源:Global.asax.cs

示例2: TestLeapPlayerLoop

        public void TestLeapPlayerLoop()
        {
            for (int i = 0; i < 3; i++)
            {
                var testOver = new ManualResetEventSlim();
                var timeoutTimer = new Timer(10000);

                var player = new LeapPlayer(@"frames\rotate_1.frames");
                player.LoopOutput = true;

                var bytesExpected = player.FileSizeInBytes * 3;

                Action<Frame> frameListener = frame =>
                    {
                        timeoutTimer.Stop();
                        timeoutTimer.Start();
                        if (player.TotalBytesRead >= bytesExpected)
                        {
                            testOver.Set();
                        }
                    };
                player.FrameReady += frameListener;

                timeoutTimer.Elapsed += (sender, args) => testOver.Set();
                player.StartConnection();

                timeoutTimer.Start();
                
                testOver.Wait();

                player.StopConnection();

                Assert.IsTrue(player.TotalBytesRead >= bytesExpected);
            }
        }
开发者ID:i2e-haw-hamburg,项目名称:gesture-recognition,代码行数:35,代码来源:LeapPlayerTest.cs

示例3: TakePictureInternal

        protected override void TakePictureInternal(Action<byte[]> callback)
        {
            List<byte[]> pictures = new List<byte[]>();

            var timer = new System.Timers.Timer(3000);

            int count = 0;
            timer.Elapsed += (sender, args) =>
            {
                ++count;
                if (count > 3)
                {
                    timer.Stop();
                    byte[] result = ProcessImages(pictures);
                    callback(result);
                    return;
                }

                timer.Stop();
                ImageProcessor.DoTakePicture(stream =>
                {
                    pictures.Add(stream);
                    timer.Start();
                });
            };

            timer.Start();
        }
开发者ID:kobyb1988,项目名称:PhotoBox,代码行数:28,代码来源:StripeImageProcessor.cs

示例4: Init

		public void Init()
		{
			var timer = new System.Timers.Timer();
			timer.Interval = 100;
			timer.Elapsed += async (_, __) =>
			{
				timer.Stop();
				App.Current.Dispatcher.BeginInvoke(new Action(async () =>
				{
					this.Measurement = await this.sensor.MeasureAsync();
					timer.Start();
				}));
			};
			timer.Start();
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:15,代码来源:MainWindowViewModel.cs

示例5: OnStart

      protected override void OnStart(string[] args) {
         base.OnStart(args);
         switch (ReceiverKind) {
            case SupportedReceiver.RoyalTek:
               _reader = new RoyalTekReader(Port, 0);
               ((RoyalTekReader)_reader).Frequency = Frequency;
               break;
            default:
               Log.Warn("{0} recieved is unsupported.", ReceiverKind);
               break;
         }
         if (_reader != null) {
            _reader.TmcTransmissionArrived += onDataArrived;

            var tm = new System.Timers.Timer {
               Interval = 30000,
               AutoReset = true
            };
            tm.Elapsed += new System.Timers.ElapsedEventHandler((o, a) => _sendTrafficState());
            tm.Start();

            var lookup = new TmcLookup(_reader);
            lookup.StartLookupForTmc();
            
         } else {
            throw new NotSupportedException("Unable to initialize serial TMC reader");
         }
      }
开发者ID:borkaborka,项目名称:gmit,代码行数:28,代码来源:SerialTmcProvider.cs

示例6: Main

        static void Main(string[] args)
        {
            TimeSpan TsStart = new TimeSpan(DateTime.Now.Ticks);
            String[] CmdArgs= System.Environment.GetCommandLineArgs();
            if (CmdArgs.Length > 1)
            {
                //参数0是它本身的路径
                String FileName = CmdArgs[1].ToString();
                String Dir = CmdArgs[2].ToString();
                String Url = CmdArgs[3].ToString();
                SnapShot sp = new SnapShot();
                sp.FileName = FileName;// "test.jpg";
                sp.Dir = Dir; //@"D:\web\7.03\eweb_lifetour";
                sp.Url = Url; //@"http://lifetour20.travelindex.com.tw/eWeb/GO/V_GO_Detail.asp?MGRUP_CD=0000&GRUP_CD=0000141015A&SUB_CD=GO&JOIN_TP=1";
                sp.Save();

            }

            System.Timers.Timer tmr = new System.Timers.Timer(20000);
            tmr.Elapsed += delegate
            {
                Environment.Exit(0);
            };
            tmr.Start();
            Console.ReadKey();
        }
开发者ID:CowellJackli,项目名称:AutoRunSnapShot,代码行数:26,代码来源:Program.cs

示例7: ClassWithFinalizer

 public ClassWithFinalizer()
 {
     _sillyTimer = new System.Timers.Timer(100);
     _sillyTimer.Elapsed +=
         (a, b) => Console.WriteLine("Still Alive");
     _sillyTimer.Start();
 }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:7,代码来源:Program.cs

示例8: OnStart

 protected override void OnStart(string[] args)
 {
     ATFEnvironment.Log.logger.Info(string.Format("Test Case Manager Windows Service is starting..."));
     timer = new System.Timers.Timer(1000 * 60 * 60 * 6);//6 hours
     timer.Elapsed += MonitorTestCases;
     timer.Start();
 }
开发者ID:wangn6,项目名称:rep2,代码行数:7,代码来源:TestCaseManager.WinService.cs

示例9: OnStartUp

 public override void OnStartUp()
 {
     _timer = new Timer(1000);
     //_timer.Elapsed += Elapsed;
     _timer.Start();
     Elapsed(null, null);
 }
开发者ID:hepa,项目名称:symo,代码行数:7,代码来源:MonitoringServiceHost.cs

示例10: OutputTCBase

 public OutputTCBase(Protocol protocol, string devicename, string ip, int port, int deviceid, byte[] hw_status, bool isconnected )
     : base(protocol, devicename, ip, port, deviceid, hw_status,  isconnected)
 {
     tmrCheckOutput = new System.Timers.Timer(outputCompareMin*1000 * 60);
     tmrCheckOutput.Elapsed += new System.Timers.ElapsedEventHandler(tmrCheckOutput_Elapsed);
     tmrCheckOutput.Start();
 }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:7,代码来源:OutputTCBase.cs

示例11: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     tim = new System.Timers.Timer(25000);
     tim.Elapsed += new System.Timers.ElapsedEventHandler(CheckPageAgain);
     tim.Start();
     CheckPageAgain(null, null);
 }
开发者ID:eulalie367,项目名称:littleapps,代码行数:7,代码来源:Form1.cs

示例12: Screensaver

        public Screensaver()
        {
            App.splashWindow.StatusUpdate("Screensaver wird initialisiert");
            InitializeComponent();

            System.Timers.Timer timer = new System.Timers.Timer();

            timer.Elapsed += timer_Tick;

            timer.Interval = 2000;
            timer.Start();

            d.Add(0, "VVK");
            d.Add(1, "Games");
            d.Add(2, "MVV");
            d.Add(3, "Schwarzes Brett");
            d.Add(4, "News");
            d.Add(5, "Raumplan");

            DoubleAnimation OpacityAnim = new DoubleAnimation(.2, 1, new Duration(TimeSpan.FromSeconds(1)), FillBehavior.Stop);
            OpacityAnim.AutoReverse = true;
            OpacityAnim.RepeatBehavior = RepeatBehavior.Forever;
            startLabel.BeginAnimation(Label.OpacityProperty, OpacityAnim);

            DoubleAnimation OpacityAnim2 = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.HoldEnd);

            OpacityAnim2.Completed+=new EventHandler(OpacityAnim2_Completed2);
            mainWindow.BeginAnimation(Label.OpacityProperty, OpacityAnim2);
            App.splashWindow.StatusUpdate("Screensaver ist bereit");
        }
开发者ID:pittruff,项目名称:myStik,代码行数:30,代码来源:Screensaver.xaml.cs

示例13: GameCoordinator

        public GameCoordinator(uint appID, SteamClient steamClient, CallbackManager callbackManager)
        {
            // Map gc messages to our callback functions
            GCMessageMap = new Dictionary<uint, Action<IPacketGCMsg>>
            {
                { (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome, OnClientWelcome },
                { (uint)EGCItemMsg.k_EMsgGCUpdateItemSchema, OnItemSchemaUpdate },
                { (uint)EGCBaseMsg.k_EMsgGCSystemMessage, OnSystemMessage },
                { (uint)EGCBaseClientMsg.k_EMsgGCClientConnectionStatus, OnClientConnectionStatus },
                { (uint)4008 /* TF2's k_EMsgGCClientGoodbye */, OnClientConnectionStatus }
            };

            this.AppID = appID;
            this.SteamClient = steamClient;
            this.SteamGameCoordinator = SteamClient.GetHandler<SteamGameCoordinator>();
            this.Name = string.Format("GC {0}", appID);

            // Make sure Steam knows we're playing the game
            Timer = new System.Timers.Timer();
            Timer.Elapsed += OnTimerPlayGame;
            Timer.Interval = TimeSpan.FromMinutes(5).TotalMilliseconds;
            Timer.Start();

            Timer = new System.Timers.Timer();
            Timer.Elapsed += OnTimer;

            callbackManager.Register(new Callback<SteamGameCoordinator.MessageCallback>(OnGameCoordinatorMessage));
        }
开发者ID:TomasDuda,项目名称:SteamDatabaseBackend,代码行数:28,代码来源:GameCoordinator.cs

示例14: GetIntAsync

        public static Task<int> GetIntAsync(CancellationToken token = default(CancellationToken))
        {
            var tcs = new TaskCompletionSource<int>();

            if (token.IsCancellationRequested)
            {
                tcs.SetCanceled();
                return tcs.Task;
            }

            var timer = new System.Timers.Timer(3000);
            timer.AutoReset = false;
            timer.Elapsed += (s, e) =>
            {
                tcs.TrySetResult(10);
                timer.Dispose();
            };

            if (token.CanBeCanceled)
            {
                token.Register(() => {
                    tcs.TrySetCanceled();
                    timer.Dispose();
                });
            }

            timer.Start();
            return tcs.Task;
        }
开发者ID:hctan,项目名称:AsyncTest,代码行数:29,代码来源:AsyncFactory.cs

示例15: YADataDBURLQueue

        public YADataDBURLQueue(string dbConnectionString, int mode = 0)
        {
            Console.WriteLine("Создаем очередь");
            tick += Tick;
            work = false;
            jobs_made = 0;
            got_jobs = new Queue<DataDBURLJob>(0);
            photo_aps = new Queue<DirtyApartments>(0);
            disposed = false; 
            //обновляем ссылку на подключение к базе для всяких асинхронных передач данных в духе ошибок
            ddbs = new DataDBAsynchService(dbConnectionString);
            ddbs.WriteErrorMessage(dbConnectionString, 0, "", "start");
            //получаем задания на парсинг
            jobs = new DataDBURLJobs(ddbs, mode, false);
            //jobs.SetJobToStartOrStop(true);
            t_fill = new System.Timers.Timer();
            t_fill.Elapsed += new System.Timers.ElapsedEventHandler(fill_timer);
            t_fill.Interval = 30000;
            t_restart = new System.Timers.Timer();
            t_restart.Elapsed += new System.Timers.ElapsedEventHandler(restart_timer);
            //рестартить раз в 12 часов
            t_restart.Interval = 12 * 60 * 60 * 1000;
            this.mode = mode;

            pq = new PhotoQueue(ddbs);
            arw = new AsyncRunWork();
            ap = new apartments();
            work = true;
            t_fill.Start();
            t_restart.Start();
            Console.WriteLine("Создали очередь");
        }
开发者ID:molec1,项目名称:MySPM_NewParsers,代码行数:32,代码来源:YADataDBURLQueue.cs


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