Example #1
0
        public void PublishNews(string name, string detail)
        {
            NewsEventArgs na = new NewsEventArgs(name, detail);

            /* If news arrived and ready to publish then call OnNewsArrival
             * method which will execute subscribed methods.*/
            OnNewsArrival(na);
        }
Example #2
0
        /* If anyone subscribe for the notification then this method will
         * invoke each of the subscribed method and execute all. */
        protected virtual void OnNewsArrival(NewsEventArgs args)
        {
            EventHandler <NewsEventArgs> newsHandler = NewsEvent;

            if (newsHandler != null)
            {
                newsHandler(this, args);
            }
        }
Example #3
0
 /* When news arrived if subscribe then execute this method.*/
 private void PublishArrivedNews(object sender, NewsEventArgs na)
 {
     Console.WriteLine("Published:\n{0} news.", na.Title);
 }
Example #4
0
 /* When news arrived if subscribe then execute this method.*/
 private void ReviewOnArrivedNews(object sender, NewsEventArgs na)
 {
     Console.WriteLine("Reviewed:\n{0},\t{1}", na.Title, na.Detail);
 }