示例#1
0
        static void Main(string[] args)
        {
            Publisher pub = new Publisher(3);
            Subscriber sub1 = new Subscriber(pub, "Subscriber 1");

            DateTime now = DateTime.Now;
            DateTime future = now.AddSeconds(10);

            while (now < future)
            {
                pub.ShowDigitValue();
                now = DateTime.Now;
            }
        }
示例#2
0
 public void Unregister(Publisher pub)
 {
     pub.CustomEvent -= HandleCustomEvent;
 }
示例#3
0
 public Subscriber(Publisher pub, string name)
 {
     pub.CustomEvent += HandleCustomEvent;
     this.name = name;
 }