﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Few questions about threads and waitwindow</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 17:01:24 GMT</lastBuildDate><ttl>20</ttl><item><title>Few questions about threads and waitwindow</title><link>http://forum.strataframe.net/FindPost9847.aspx</link><description>I need to invoke the vb threading gods of the forum.&amp;nbsp; I'm very new to delegates and cross form method calls etc.&lt;P&gt;I have a main form with a class level WaitWindow that methods on the form can show, hide, update whatever.&amp;nbsp; This form makes several calls to a class that performs a lot of data manipulation.&amp;nbsp; Some of these take a long time, so I decided updating the WaitWindow would be nice to let the user know something is going on.&lt;/P&gt;&lt;P&gt;My declaration of the WaitWindow on the form.&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WithEvents&lt;/FONT&gt;&lt;FONT size=2&gt; loWaitWindow &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.Messaging.WaitWindow&lt;P&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;Here is my method to Update that WaitWindow&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; UpdateWaitWindow(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; lcMessage &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'-- Update the Wait Window Message&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.loWait&amp;#119;indow.Message = lcMessage&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;And on my class that does the data manipulation, I added this delegate&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Delegate&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; UpdateWaitWindow(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; lcMessage &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;And I added a Reference to the main Form to call UpdateWaitWindow on&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Shared&lt;/FONT&gt;&lt;FONT size=2&gt; loForm &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; frmProjectMain = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(Application.OpenForms(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"frmProjectMain"&lt;/FONT&gt;&lt;FONT size=2&gt;), frmProjectMain)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;Now should I be able to call this UpdateWaitWindow by simply ?&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;!--StartFragment--&gt;&lt;FONT size=2&gt;&lt;P&gt;loForm.Invoke(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;FONT size=2&gt; UpdateWaitWindow(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AddressOf&lt;/FONT&gt;&lt;FONT size=2&gt; loForm.UpdateWaitWindow), &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"new message"&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]</description><pubDate>Mon, 02 Jul 2007 14:50:45 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item><item><title>RE: Few questions about threads and waitwindow</title><link>http://forum.strataframe.net/FindPost9914.aspx</link><description>Great.&amp;nbsp; Thanks Ben.&lt;/P&gt;&lt;P&gt;Robin Giltner</description><pubDate>Mon, 02 Jul 2007 14:50:45 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item><item><title>RE: Few questions about threads and waitwindow</title><link>http://forum.strataframe.net/FindPost9876.aspx</link><description>Yes, that's how you would do it.&amp;nbsp; Now, when you're calling the Invoke of the ISynchronizeInvoke interface (on any Control object, like a form), you have to make sure that the control's thread is not busy.&amp;nbsp; Meaning, if you try to Invoke() from the main thread back to the main thread, you'll enter deadlock... the CLR waits until the main thread is not busy before calling the invoked method.</description><pubDate>Mon, 02 Jul 2007 08:46:51 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Few questions about threads and waitwindow</title><link>http://forum.strataframe.net/FindPost9853.aspx</link><description>[quote]I need to invoke the vb threading gods of the forum. [/quote]&lt;br&gt;
&lt;br&gt;
Well, that leaves me out, even though I do own a sewing machine and I'm not afraid to use it!  :P&lt;br&gt;
&lt;br&gt;
Sorry for the unhelpful reply...it's been a hard week, it's friday, I've been up way too long and it's summer time, and silliness just bubble to the fore.  :hehe:&lt;br&gt;
&lt;br&gt;
I'll be watching the thread (er...no pun intended) to learn more about threads though!</description><pubDate>Fri, 29 Jun 2007 11:10:11 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>