using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
Timer timer = new Timer();//事件拥有者
timer.Interval = 1000;
timer.Elapsed += Boy.Action; //事件与事件响应器的约定
timer.Elapsed += Girl.Action;
timer.Start();
Console.ReadLine();
}
}
class Boy //事件响应者
{
internal static void Action(object sender, ElapsedEventArgs e)//事件处理器
{
Console.WriteLine("Jump");
}
}
class Girl
{
internal static void Action(object sender, ElapsedEventArgs e)
{
Console.WriteLine("Dance");
}
}
}版权声明:本文为weixin_68861604原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。