<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx</link><description>While helping some Windows API folks with some sample code this week, I stumbled upon...uh...I mean “carefully researched” an issue that you might find handy. 
 You may be aware that the RaiseEvent statement automatically checks to verify if an event</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#10209708</link><pubDate>Tue, 13 Sep 2011 02:59:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10209708</guid><dc:creator>Jordan</dc:creator><description>&lt;p&gt;This code really doesn&amp;#39;t even compile???? &amp;nbsp;What is going on here?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10209708" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9953290</link><pubDate>Tue, 26 Jan 2010 00:13:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9953290</guid><dc:creator>cember makinası</dc:creator><description>&lt;p&gt;could not help me get a code snippet immediately thanks&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9953290" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9930475</link><pubDate>Tue, 01 Dec 2009 00:51:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9930475</guid><dc:creator>Yu Heng Zhou</dc:creator><description>&lt;p&gt;it is really useful for me.&lt;/p&gt;
&lt;p&gt;SolutionFoundEvent is a hiden member, haha!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9930475" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9907760</link><pubDate>Thu, 15 Oct 2009 17:13:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907760</guid><dc:creator>help</dc:creator><description>&lt;p&gt;Any idea what to do if you assigned an eventhandler and it is still nothing? &lt;/p&gt;
&lt;p&gt;I had four event handlers assigned that work, then added a fifth in the same location that always shows up as Nothing. &amp;nbsp;The others still work properly and keep their pointers.&lt;/p&gt;
&lt;p&gt;(using ASP.NET 3.5 sp1 with VB, by the way)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9907760" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9907594</link><pubDate>Thu, 15 Oct 2009 10:18:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907594</guid><dc:creator>DeWolf</dc:creator><description>&lt;p&gt;I might be missing the point here, but why not use a custom event. &amp;nbsp;A RaiseEvent accessor is used in a custom event to specify the statements to execute when the event is raised using the RaiseEvent statement. &amp;nbsp; Typically, this invokes a list of delegates maintained by the AddHandler and RemoveHandler accessors. &amp;nbsp;But this can also be used to check for Nothing.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9907594" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9903080</link><pubDate>Mon, 05 Oct 2009 09:06:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9903080</guid><dc:creator>Waleed El-Badry</dc:creator><description>&lt;p&gt;Thanks Doug,&lt;/p&gt;
&lt;p&gt;It was really useful to me.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903080" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9902025</link><pubDate>Thu, 01 Oct 2009 23:28:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9902025</guid><dc:creator>VBTeam</dc:creator><description>&lt;p&gt;Changed &amp;quot;public&amp;quot; to &amp;quot;private&amp;quot;. Thanks for the catch.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9902025" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9902006</link><pubDate>Thu, 01 Oct 2009 22:27:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9902006</guid><dc:creator>Chance</dc:creator><description>&lt;p&gt;&amp;quot;...it creates a public variable for the event..&amp;quot;&lt;/p&gt;
&lt;p&gt;Not really. &amp;nbsp;It creates a private member in the class. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9902006" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9901241</link><pubDate>Wed, 30 Sep 2009 13:13:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9901241</guid><dc:creator>Héctor</dc:creator><description>&lt;p&gt;I was already aware of this, but since the VB compiler already adds the code and checks for you is not like in C# where this is a common practice. So I wonder... when is this actually needed? never found a situation where the event variable is nothing. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9901241" width="1" height="1"&gt;</description></item><item><title>re: Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/b/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx#9900657</link><pubDate>Tue, 29 Sep 2009 10:55:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9900657</guid><dc:creator>Nah</dc:creator><description>&lt;p&gt;Is this really a good idea?&lt;/p&gt;
&lt;p&gt;I would expect the behaviour to be exactly the same if there is no event handler as if there is one that ends up doing nothing.&lt;/p&gt;
&lt;p&gt;The only &amp;quot;safe&amp;quot; use I can imagine is perhaps skipping some checks after the event that you otherwise would have to do in case something was changed during the event.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900657" width="1" height="1"&gt;</description></item></channel></rss>