<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Close All Forms in an Application in a Thread-Safe Manner</title>
	<atom:link href="http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/</link>
	<description>C# Development</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:14:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: TamusJRoyce</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-939</link>
		<dc:creator>TamusJRoyce</dc:creator>
		<pubDate>Mon, 03 Oct 2011 14:30:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-939</guid>
		<description>List forms = new List(Application.Forms)

for (int index = 0; index &lt; forms.count; ++index)
{
  if !(forms(index) is me)
  {
    forms(index).Dispose()
  } // End if
} // End for


Try this once more.  It was parsing my comment like html.</description>
		<content:encoded><![CDATA[<p>List forms = new List(Application.Forms)</p>
<p>for (int index = 0; index &lt; forms.count; ++index)<br />
{<br />
  if !(forms(index) is me)<br />
  {<br />
    forms(index).Dispose()<br />
  } // End if<br />
} // End for</p>
<p>Try this once more.  It was parsing my comment like html.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TamusJRoyce</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-938</link>
		<dc:creator>TamusJRoyce</dc:creator>
		<pubDate>Mon, 03 Oct 2011 14:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-938</guid>
		<description>List forms = new List(Application.Forms)

Sorry.  In dumb vb mindset at the moment ;)</description>
		<content:encoded><![CDATA[<p>List forms = new List(Application.Forms)</p>
<p>Sorry.  In dumb vb mindset at the moment <img src='http://www.csharp411.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TamusJRoyce</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-937</link>
		<dc:creator>TamusJRoyce</dc:creator>
		<pubDate>Mon, 03 Oct 2011 14:26:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-937</guid>
		<description>List forms = new List(Application.Forms)

for (int index = 0; index &lt; forms.count; ++index)
{
  if !(forms(index) is me)
  {
    forms(index).Dispose()
  } // End if
} // End for

I think this is much simpler than using an array.  Little more expensive.  But many times more manageable.

I agree with using .Dispose() over .Close().  I&#039;m not sure if it invokes the same events as .Close() does.  Which means Form.Closing/form.Closed might not run?  Just depends if you are handing those events or not (or they may still run, untested).</description>
		<content:encoded><![CDATA[<p>List forms = new List(Application.Forms)</p>
<p>for (int index = 0; index &lt; forms.count; ++index)<br />
{<br />
  if !(forms(index) is me)<br />
  {<br />
    forms(index).Dispose()<br />
  } // End if<br />
} // End for</p>
<p>I think this is much simpler than using an array.  Little more expensive.  But many times more manageable.</p>
<p>I agree with using .Dispose() over .Close().  I&#039;m not sure if it invokes the same events as .Close() does.  Which means Form.Closing/form.Closed might not run?  Just depends if you are handing those events or not (or they may still run, untested).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: G</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-936</link>
		<dc:creator>G</dc:creator>
		<pubDate>Fri, 19 Aug 2011 09:38:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-936</guid>
		<description>I ended up using .Dispose() instead of .Close() and this seemeed to get ride of the Dialog box infront of my Form.
By the way I wanted to close all open forms except my main form. This is when the issue occured.</description>
		<content:encoded><![CDATA[<p>I ended up using .Dispose() instead of .Close() and this seemeed to get ride of the Dialog box infront of my Form.<br />
By the way I wanted to close all open forms except my main form. This is when the issue occured.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: G</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-935</link>
		<dc:creator>G</dc:creator>
		<pubDate>Thu, 18 Aug 2011 12:51:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-935</guid>
		<description>I am having a issue where I cannot close a Form that has a dialog error message box on top of a form.

When I try using the .Close() method on the form it also does not close the form because it still has a open dialog on top of it.

So when I do a (Application.OpenForms) it does not show the message box form as part of the count.

Think it relates to Kirill question:

&#039;how about close dialog boxes? opened by the forms? :)&#039;</description>
		<content:encoded><![CDATA[<p>I am having a issue where I cannot close a Form that has a dialog error message box on top of a form.</p>
<p>When I try using the .Close() method on the form it also does not close the form because it still has a open dialog on top of it.</p>
<p>So when I do a (Application.OpenForms) it does not show the message box form as part of the count.</p>
<p>Think it relates to Kirill question:</p>
<p>&#8216;how about close dialog boxes? opened by the forms? <img src='http://www.csharp411.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vignesh</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-934</link>
		<dc:creator>Vignesh</dc:creator>
		<pubDate>Fri, 10 Jun 2011 18:12:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-934</guid>
		<description>This thread helped me.. thanks a lot..</description>
		<content:encoded><![CDATA[<p>This thread helped me.. thanks a lot..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manju</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-933</link>
		<dc:creator>manju</dc:creator>
		<pubDate>Fri, 03 Jun 2011 06:20:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-933</guid>
		<description>Its working fine</description>
		<content:encoded><![CDATA[<p>Its working fine</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirill</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-932</link>
		<dc:creator>Kirill</dc:creator>
		<pubDate>Wed, 01 Jun 2011 08:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-932</guid>
		<description>how about close dialog boxes? opened by the forms? :)</description>
		<content:encoded><![CDATA[<p>how about close dialog boxes? opened by the forms? <img src='http://www.csharp411.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jainlal</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-931</link>
		<dc:creator>jainlal</dc:creator>
		<pubDate>Sat, 30 Apr 2011 06:15:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-931</guid>
		<description>It is working nice. great!...</description>
		<content:encoded><![CDATA[<p>It is working nice. great!&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-930</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 13 Oct 2010 14:29:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/close-all-forms-in-a-thread-safe-manner/#comment-930</guid>
		<description>Ryan&#039;s change looks more promising, although I&#039;m not sure what exactly happens when creating a FormCollection (does it simply make a reference to Application.OpenForms or does it copy it? And does the operation behind that copy also have the same problem?)

The static OpenForms function runs based on a foreach loop of Application.OpenForms itself, which can be changed via other means during its cycle. You&#039;re creating a second array, which is good, but the process used to create the second list is also vulnerable to a form closing during its execution.

My situation is different from just doing a window cleanup, though. I&#039;m using it in threads to check and see if program was closed so the threads don&#039;t cause it to hang. They check often so once in a great while my program runs into this exception.</description>
		<content:encoded><![CDATA[<p>Ryan&#8217;s change looks more promising, although I&#8217;m not sure what exactly happens when creating a FormCollection (does it simply make a reference to Application.OpenForms or does it copy it? And does the operation behind that copy also have the same problem?)</p>
<p>The static OpenForms function runs based on a foreach loop of Application.OpenForms itself, which can be changed via other means during its cycle. You&#8217;re creating a second array, which is good, but the process used to create the second list is also vulnerable to a form closing during its execution.</p>
<p>My situation is different from just doing a window cleanup, though. I&#8217;m using it in threads to check and see if program was closed so the threads don&#8217;t cause it to hang. They check often so once in a great while my program runs into this exception.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

