Groups | Blog | Home
all groups > dotnet faqs > december 2003 >

dotnet faqs : WithEvents ???


mreid NO[at]SPAM exhibitworks.com
12/24/2003 10:56:38 AM
Is there any additional overhead for declaring a variable using the
WithEvents keyword even if none of the events are being handled?

Scott M.
12/24/2003 11:17:53 AM
I would imagine yes, but I can't give specifics.


[quoted text, click to view]

NoOne
12/24/2003 12:02:15 PM
Is it possible that its just a keyword for the visual basic compiler that
connects an object's events to some handlers? C# and Visual Basic both
compile to IL, if it did have overhead (other than compilation) it would
have to show up there.


[quoted text, click to view]

solex
12/24/2003 12:14:44 PM
I am pondering here but would imagine that there is no overhead because I
would again imagine that the MSIL compiler is very efficient and would
realize that there are no eventsinks for the object and hence remove and
event handling code.

A question for you is why would you declare an object withEvents if you do
not plan on using them?


[quoted text, click to view]

Tom Spink
12/24/2003 6:40:25 PM
Hi NoOne,

You are correct, WithEvents (in conjuction with the Handles clause) removes
the arduous task of AddHandler and RemoveHandler on all events for any
controls you make.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations


[quoted text, click to view]

AddThis Social Bookmark Button