本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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
}
示例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...");
}
示例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;
}
示例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();
}
示例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);
}
示例9: Main
static void Main()
{
Timer newTimer = new Timer(1, 10);
newTimer.TimeChanged += Timer_TimeChanged;
newTimer.Run();
}
示例10: Main
static void Main()
{
Timer timer = new Timer(12, 3);
SomeDelegate d = PrintMessage;
timer.Run(d);
}
示例11: Main
static void Main()
{
Timer testTimer = new Timer(Test, 4, 1500);
testTimer.Run();
}