By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,665 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,665 IT Pros & Developers. It's quick & easy.

Why events, why not just delegates?

P: n/a
It is still unclear to me why we would use events when delegates seem to do
just fine. People say that events make it so the publisher doesn't need to
know about the listeners. What does that mean? Why are events better than
delegates? Thanks
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Marty,
The way I understand it Events are to Delegate fields that Properties are to
other fields.

The event encapsulates & protects the underlying delegate value.

Chris Sells' book "Windows Forms Programming in C#" from Addison Wesley has
a chapter explaining the relationship. The story is also available on Code
Project:

http://www.thecodeproject.com/csharp...te_bedtime.asp

Hope this helps
Jay

"Marty McDonald" <mc******@wsdot.wa.gov> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
It is still unclear to me why we would use events when delegates seem to do just fine. People say that events make it so the publisher doesn't need to know about the listeners. What does that mean? Why are events better than
delegates? Thanks

Jul 21 '05 #2

P: n/a
Marty,
I just found the story on Chris Sells web site itself, where I was
originally looking for it.

http://www.sellsbrothers.com/writing...=delegates.htm

Same story, different location & formatting.

Hope this helps
Jay

"Marty McDonald" <mc******@wsdot.wa.gov> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
It is still unclear to me why we would use events when delegates seem to do just fine. People say that events make it so the publisher doesn't need to know about the listeners. What does that mean? Why are events better than
delegates? Thanks

Jul 21 '05 #3

P: n/a
Hi Marty,

Jay's link is very good.
You may also take a look at the links below.

Events Tutorial
http://msdn.microsoft.com/library/de...us/csref/html/
vcwlkEventsTutorial.asp
Delegates Tutorial
http://msdn.microsoft.com/library/de...us/csref/html/
vcwlkdelegatestutorial.asp

Raising Events and Responding to Events
http://msdn.microsoft.com/library/de...us/dndotnet/ht
ml/raiserespeven.asp
Events and Delegates
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconeventsdelegates.asp

If you have any related question, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: "Marty McDonald" <mc******@wsdot.wa.gov>
Subject: Why events, why not just delegates?
Date: Thu, 23 Oct 2003 12:01:13 -0700
Lines: 6
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <#m**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: 164.110.202.164
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:113005
X-Tomcat-NG: microsoft.public.dotnet.general

It is still unclear to me why we would use events when delegates seem to do
just fine. People say that events make it so the publisher doesn't need to
know about the listeners. What does that mean? Why are events better than
delegates? Thanks


Jul 21 '05 #4

P: n/a
Hi Marty,

If you still have questions on this issue, please reply the thread to let
us know you need further assistance.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.