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


C# Timer.Run方法代码示例

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


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

示例1: Main

        static void Main()
        {
            Timer myTimer = new Timer();

            Console.WriteLine("Calling the timer with no methods attached:");
            myTimer.Run(1, 1);

            Console.WriteLine("Adding one method to the timer and running it for 3 seconds (each 0.5 seconds):");
            myTimer.AddMethod(FirstMethod);
            myTimer.Run(3, 0.5);

            Console.WriteLine("Adding two more methods and running the timer again for 3 seconds (each 1 second):");
            myTimer.AddMethod(SecondMethod);
            myTimer.AddMethod(ThirdMethod);
            myTimer.Run(3, 1);
        }
开发者ID:MihailGochev,项目名称:Telerik,代码行数:16,代码来源:Test.cs

示例2: Main

        static void Main(string[] args)
        {
            var timer = new Timer();
            var panasonic = new Tv("Panasonic");
            var lg = new Tv("LG");
            var human = new Human("John");

            timer.TimerCounted += panasonic.Subscribed;
            timer.TimerCounted += lg.Subscribed;
            timer.TimerCounted += human.Subscribed;
            timer.Run(1000);

            timer.TimerCounted -= panasonic.Subscribed;
            timer.Run(5000);

            Console.ReadKey();
        }
开发者ID:opolkosergey,项目名称:BSU.ASP.1501.Day7.Opolko,代码行数:17,代码来源:Program.cs

示例3: Main

    public static void Main()
    {
        Timer timer = new Timer(10, 1000);
        timer.TimeChanged += new TimeChangedEventHandler(Timer_TimeChanged);

        Console.WriteLine("Timer started for 10 ticks at interval 1000 ms.");
        timer.Run();
    }
开发者ID:SivaCse,项目名称:Object-Oriented-Programming,代码行数:8,代码来源:TimerDemo.cs

示例4: Main

        static void Main()
        {
            Timer timer1 = new Timer(2,5);
            Timer timer2 = new Timer(2);

            timer1.timerEvent += Test1;
            timer1.timerEvent += Test2;
            timer1.Run();  //executed 5 times
            Console.WriteLine();
            timer2.timerEvent += Test3;
            timer2.Run();  //executed 255 times
        }
开发者ID:AYankova,项目名称:CSharp,代码行数:12,代码来源:TimerTest.cs

示例5: Main

        static void Main(string[] args)
        {
            var timer = new Timer();

            var echo1 = new Echo1();
            var echo2 = new Echo2();

            echo2.Subscribe(timer);
            echo1.Subscribe(timer);

            timer.Run("Some time has passed.", 2);

            timer.CountdownCompleted("Not intended to be able to run this...");
        }
开发者ID:Softwire,项目名称:Learning-C-sharp,代码行数:14,代码来源:Program.cs

示例6: Timer

        void IBehaviour.Initialize()
        {
            _moveTimer = new Timer();
            _moveTimer.Duration = 5;
            _moveTimer.TickEvent += OnMoveTimerTickEvent;
            _moveTimer.UpdateEvent += OnMoveTimerUpdateEvent;
            _moveTimer.Run();
            _waitTimer = new Timer();
            _waitTimer.Duration = 7;
            _waitTimer.TickEvent += OnWaitTimerTickEvent;

            Creature.HDirection = RandomTool.RandBool() ? HDirection.Right: HDirection.Left;
            Creature.CollisionWithTiles += Creature_CollisionWithTiles;
        }
开发者ID:mokujin,项目名称:DN,代码行数:14,代码来源:TrollBehaviour.cs

示例7: TimedEventTest

        public static void TimedEventTest()
        {
            var timer = new Timer(5);

            var myStudents = new ClassOfStudents();

            // Student has a constuctor for testing
            // subscribing to the testing event TimedEvent
            // printing first and last name on event
            myStudents.AddStudent(new Student("1", "1", timer));
            myStudents.AddStudent(new Student("2", "2"));
            myStudents.AddStudent(new Student("3", "3", timer));

            timer.Run();
        }
开发者ID:tvmarinov,项目名称:Homework,代码行数:15,代码来源:TimerTesting.cs

示例8: FlyState

    public FlyState(AirplaneController Controller)
    {
        _plane = Controller;
        mUndeadTimer = new Timer();
        mUndeadTimer.Duration = 0.25f;
        mUndeadTimer.OnTick += OnTick;
        mUndeadTimer.Run();

        _sharpTurnTimer = new Timer();
        _sharpTurnTimer.Duration = 1.3f;
        _sharpTurnTimer.OnTick += OnSharpTurnEnd;

        _planeMaxRotation = _plane.MaxRotation;
        _planeAccelRotation = _plane.AccelRotation;
        _planeBreakRotation = _plane.BreakRotation;

        _prevBreaking = _plane.Breaking;

        EventController.Instance.Subscribe("MakeSharpTurn", this);
    }
开发者ID:ifty420,项目名称:Fly-Airplane-F18-Jets,代码行数:20,代码来源:FlyState.cs

示例9: Main

 static void Main()
 {
     Timer newTimer = new Timer(1, 10);
     newTimer.TimeChanged += Timer_TimeChanged;
     newTimer.Run();
 }
开发者ID:damy90,项目名称:Telerik-all,代码行数:6,代码来源:TimerUsingEvents.cs

示例10: Main

 static void Main()
 {
     Timer timer = new Timer(12, 3);
     SomeDelegate d = PrintMessage;
     timer.Run(d);
 }
开发者ID:Bonevm01,项目名称:OOP_ExtensionLambdaLinq,代码行数:6,代码来源:Timer.cs

示例11: Main

 static void Main()
 {
     Timer testTimer = new Timer(Test, 4, 1500);
     testTimer.Run();
 }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:5,代码来源:TestMethod.cs


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