เรื่องเกิดจากว่า ได้รับหมอบหมายให้ทำ custom control ที่บริษัท แล้วไปเห็น code ที่น่าสนใจเข้า จึงนำมาบอกกันครับ

        protected static readonly object EventProcessing = new object();
        public event EventHandler Processing {
            add {
                Events.AddHandler(EventProcessing, value);
            }
            remove {
                Events.RemoveHandler(EventProcessing, value);
            }
        }
        public virtual void OnProcessing(EventArgs e) {
           EventHandler processingHandler = (EventHandler)Events[EventProcessing];
            if (processingHandler != null) {
                       processingHandler(this, e);                        
            }

        }
 

 เป็นการประกาส event ที่สวยงามมากทีเดียว

 

 

Comment



smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

SaBUwK Blogs rating, add your blog to be rated for free
http://blogsrate.net

#1 By MHIReakwu (87.118.100.104) on 2008-06-25 00:37