1 2 3 4 5 6 7 8 9 10 11 |
public class CalcEventArgs : EventArgs //우선 이벤트를 넣을 클래스를 만들기. //멤버가 없는 클래스인 EventArgs를 상속받아야됨 class Calculator { public event EventHandler CalcStock; //이벤트를 발생시킬 Calculator클래스 안에서 //이벤트 키워드를 이용해서 이벤트 핸들러를 선언 public void Calculator(() } |
1 |
---------------- |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/////////////////////////////////////////////// delegate void CustomEvent();//delegate 선언 class EventClass { public event CustomEvent customevent; //event선언 public void Start() { if (customevent != null) { System.Threading.Thread.Sleep(1000); customevent(); } } } class CustomSample { static void handler() } Console.WriteLine("핸들러호출"); } static void Main() { EventClass e = new EventClass(); e.customevent += new CustomEvent(handler); e.Start(); } } /////////////////////////////////////////////// |
이런식인듯… 외워야지… 필요할 때 찾아쓰는 용