示例#1
0
		public static void Main(string[] args)
		{
			Console.WriteLine("Escribe un nombre y presiona enter");
			var name = Console.ReadLine();

			g = new Generator(name);

			g.GeneratingNumber += G_GeneratingNumber;

			g.GeneratingNumber1 += (sender, e) => 
			{
				var generador = sender as Generator;
				Console.WriteLine(generador.Name + " generará un número (EventHandler)");
			};

			g.EvenNumberGenerated += (sender, number) => 
			{
				Console.WriteLine("Se generó el número par: " + number + " (manejador 1)");
			};

			g.EvenNumberGenerated += G_EvenNumberGenerated;

			g.EvenNumberGeneratedAction += (obj) => 
			{  
				Console.WriteLine("Se generó el número: " + obj + " (Action 1)");
			};

			//g.EvenNumberGenerated(5);
			g.EvenNumberGeneratedAction(3);

			//g.EvenNumberGenerated = null;
			g.EvenNumberGeneratedAction = null;



			g.Start();

			System.Threading.Thread.Sleep(TimeSpan.FromMinutes(1));
		}
示例#2
0
		static void G_GeneratingNumber(Generator sender)
		{
			Console.WriteLine(sender.Name + " generará un número");
		}