示例#1
0
		public void Move()
		{
			while(tank.Fuel > 5) {
				tank.Fuel -= 2;
				if (tank.Fuel < 5) {
					TankEmptyEventArgs e = new TankEmptyEventArgs (tank.Fuel);
					tank.OnTankEmpty (e);
				} else
					Console.WriteLine ("Moving... Tank balance is {0}", tank.Fuel);	
			}
		}
示例#2
0
		// actually the subscriber
		public void Stop(object sender, TankEmptyEventArgs e)
		{
			Console.WriteLine("Engine has stoppeed. Fuel balance: {0}", e.FuelBalance);
		}
示例#3
0
		// method that raise event
		public void OnTankEmpty(TankEmptyEventArgs e)
		{
			if (tankEmpty != null)
				tankEmpty (this, e);
		}