StrataFrame Forum

Wait Window

http://forum.strataframe.net/Topic2409.aspx

By Keith Chisarik - 8/23/2006

Trying to get the SF wait window control to behave like my old friend THE wait window.



I looked thruough all the overloads and dont see the ability to pause.



I am looping through a few dozen files and want to put in enough of a pause so that each wait window displays the filename is briefly visible. Right now it processes so fast all I see is the last one.



My code:



While en.MoveNext

information = My.Computer.FileSystem.GetFileInfo(CStr(en.Current))

Me.WaitWindow1.ShowWaitWindow("", information.FullName, MicroFour.StrataFrame.Messaging.MessagingCardinalPosition.NorthEast)

'Me.WaitWindow1.HideWaitWindow()

filecount += 1

End While
By Keith Chisarik - 8/23/2006

Ill follow up with how do you pause in .NET period?



I have looked before, found not much I liked and created an empty loop from 1 to x Blush
By Trent L. Taylor - 8/23/2006

Unlike FoxPro, the Wait Windows does not share the same thread as the UI...which is a very good thing.  To add your own pause, just pause the current thread.

System.Threading.Thread.Sleep(1000)

The Wait Window is not an exact feature by feature replica otherwise it wouldn't work when you really need it to Smile  One major downside of the FoxPro Wait Window was the way it actually waited in certain scenarios.  Also, when the UI was taxed, it would not refresh properly.  That is why the SF Wait Window is actually on a separate thread than the thread you are working on.

By Trent L. Taylor - 8/23/2006

FYI, creating loops as you mentioned can be very costly on the system resources and does not truly pause the application.
By Keith Chisarik - 8/23/2006

Yes I knew it was bad but I only did it once *cough*



Now I am throughly frustrated and am going home Ermm



I added the thread.sleep(1000) line and yes, it pauses the thread (I had tried this before I asked BTW), but it doesnt refresh my wait window values. I tried it with just a label on the form. When I step through it I see the value change, but the screen never refreshes till the end of the loop.



I'll come at it and the XML import tomorrow with a fresh outlook.



Thanks for the help guys.
By Keith Chisarik - 8/24/2006

Please tell me why the below code will not work. I think it should display a wait window that says "hi" for 5 seconds, then count from 1 to 5. It does neither. Please help.



Me.WaitWindow1.Message = "hi"

Me.WaitWindow1.ShowWaitWindow()



System.Threading.Thread.Sleep(5000)



Dim x As Integer

For x = 1 To 5

Me.WaitWindow1.Message = x.ToString

Me.WaitWindow1.ShowWaitWindow()

System.Threading.Thread.Sleep(1000)

'Me.WaitWindow1.HideWaitWindow() (optional)

Next
By StrataFrame Team - 8/24/2006

Try this:

Me.WaitWindow1.ShowWaitWindow("hi")

System.Threading.Thread.Sleep(5000)

For x As Integer = 1 To 5
    Me.WaitWindow1.Message = x.ToString
    System.Threading.Thread.Sleep(1000)
Next

Me.WaitWindow1.HideWaitWindow()

By Keith Chisarik - 8/24/2006

That does nothing as well for me Ben Sad
By StrataFrame Team - 8/24/2006

Hrm, it worked for me... when are you showing that wait window? in the Load of a form? or after the form is already up?
By Keith Chisarik - 8/24/2006

I just put your code in a button click event, the simplest implementation I could think of just to get it working.
By StrataFrame Team - 8/24/2006

yeah, that's what I did as well... that's strange.  If you take out everything except

Me.WaitWindow1.ShowWaitWindow("hi")

Does it display when you click the button?

By Trent L. Taylor - 8/24/2006

I created a quick test and it seemed to work fine for me.  I attached the sample project I created.
By Keith Chisarik - 8/24/2006

If I try and put a WaitWindow with a pause in any looping structure other than a very simple one I get the error below, just a WaitWindow alone causes no error, but does not display until the end one:



As in doing a read thru an XmlTextReader or looping thru a datatable ....



************** Exception Text **************

System.Threading.ThreadAbortException: Thread was being aborted.

at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)

at System.Windows.Forms.Control.DefWndProc(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)





************** Loaded Assemblies **************

mscorlib

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

----------------------------------------

Microsoft.VisualStudio.HostingProcess.Utilities

Assembly Version: 8.0.0.0

Win32 Version: 8.0.50727.42

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.HostingProcess.Utilities/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.HostingProcess.Utilities.dll

----------------------------------------

System.Windows.Forms

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

----------------------------------------

System

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

----------------------------------------

System.Drawing

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

----------------------------------------

Microsoft.VisualStudio.HostingProcess.Utilities.Sync

Assembly Version: 8.0.0.0

Win32 Version: 8.0.50727.42

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.HostingProcess.Utilities.Sync/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll

----------------------------------------

vshost

Assembly Version: 8.0.0.0

Win32 Version: 8.0.50727.42

CodeBase: file:///V:/2005%20Projects/lightaction/lascan/bin/Release/lascan.vshost.exe

----------------------------------------

MicroFour StrataFrame Base

Assembly Version: 1.4.0.0

Win32 Version: 1.4.0.0

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/MicroFour%20StrataFrame%20Base/1.4.0.0__99fe9917f71608a7/MicroFour%20StrataFrame%20Base.dll

----------------------------------------

MicroFour StrataFrame Business

Assembly Version: 1.4.0.0

Win32 Version: 1.4.0.0

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/MicroFour%20StrataFrame%20Business/1.4.0.0__99fe9917f71608a7/MicroFour%20StrataFrame%20Business.dll

----------------------------------------

MicroFour StrataFrame DBEngine

Assembly Version: 1.4.0.0

Win32 Version: 1.4.0.0

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/MicroFour%20StrataFrame%20DBEngine/1.4.0.0__99fe9917f71608a7/MicroFour%20StrataFrame%20DBEngine.dll

----------------------------------------

MicroFour StrataFrame UI

Assembly Version: 1.4.0.0

Win32 Version: 1.4.0.0

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/MicroFour%20StrataFrame%20UI/1.4.0.0__99fe9917f71608a7/MicroFour%20StrataFrame%20UI.dll

----------------------------------------

System.Data

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll

----------------------------------------

System.Deployment

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Deployment/2.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll

----------------------------------------

System.Xml

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

----------------------------------------

Microsoft.VisualBasic

Assembly Version: 8.0.0.0

Win32 Version: 8.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll

----------------------------------------

lascan

Assembly Version: 1.0.0.0

Win32 Version: 1.0.0.0

CodeBase: file:///V:/2005%20Projects/lightaction/lascan/bin/Release/lascan.EXE

----------------------------------------

System.Web

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

----------------------------------------

lascan_BO_lib

Assembly Version: 1.0.0.0

Win32 Version: 1.0.0.0

CodeBase: file:///V:/2005%20Projects/lightaction/lascan/bin/Release/lascan_BO_lib.DLL

----------------------------------------

System.Configuration

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

----------------------------------------

System.Transactions

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll

----------------------------------------

System.EnterpriseServices

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

----------------------------------------

Accessibility

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

----------------------------------------



************** JIT Debugging **************

To enable just-in-time (JIT) debugging, the .config file for this

application or computer (machine.config) must have the

jitDebugging value set in the system.windows.forms section.

The application must also be compiled with debugging

enabled.



For example:











When JIT debugging is enabled, any unhandled exception

will be sent to the JIT debugger registered on the computer

rather than be handled by this dialog box.
By Keith Chisarik - 8/24/2006

Ben Chase (08/24/2006)
yeah, that's what I did as well... that's strange. If you take out everything except

Me.WaitWindow1.ShowWaitWindow("hi")

Does it display when you click the button?


yes sir it does........
By Ralph - 11/26/2006

Hi,



found something out about it:



--------------------

private void button2_Click(object sender, EventArgs e)

{

//-- Show the wait window

this.waitWindow1.ShowWaitWindow("TITLE!", "MESSAGE!", MicroFour.StrataFrame.Messaging.MessagingCardinalPosition.Center);

//-- Pause the thread

System.Threading.Thread.Sleep(500);

//-- Hide the wait window

this.waitWindow1.HideWaitWindow();

}

-------------------



sleep(500) will let sleeping the system 500ms and seems to keep the wait window from showing. After that the HideWaitWindow() takes place immediately, so the waitWindow is never shown.



Comment out the HideWaitWindow and try it with Sleep(5000).



Bug or feature? ;-)



As a workaround one can use something from the infoBox class, which will work as expected.



Friendly greetings,



Ralph
By Keith Chisarik - 11/26/2006

Thanks Ralph, I had given up on Wait Window.... Ill give this a shot. Though I do need it to work with a sleep() of less than 5000



Smile




By Ralph - 11/26/2006

Hello Keith,



Keith Chisarik (11/26/2006)
Thanks Ralph, I had given up on Wait Window.... Ill give this a shot. Though I do need it to work with a sleep() of less than 5000





sorry, maybe I expressed something wrong: I meant _not_ that it is working with a sleep(5000). But one can see that the waitWindow will arise 5 seconds after that sleep, as long as the 'HideWaitWindow()' is commented out or deleted, excluded from executing.



If a HideWaitWindow() is executed, the waitWindow will never be shown.



Seems like the sleep(...) will let sleeping the system, preventing the waitWindow from becoming visible, and the HideWaitWindow()-command will hide a waitWindow never seen...



HTH,



best regards, Ralph
By StrataFrame Team - 11/27/2006

Most likely, the problem is coming from the way that the wait window is being shown... all showing and unshowing of the WaitWindow must be done on the main thread of the application (the UI thread) through synchronization to avoid cross-thread exceptions.  By default, the WaitWindow fades in rather than just poping in, so, if you're doing all of your work on the main thread rather than a side thread, the main thread does not have time to process the fading in/out of the WaitWindow.  So, you might try to set the WaitWindow to show immediately, rather than fade in/out, or start up a background thread that shows the wait window, processes the information and then hides the wait window, allowing the main thread time to hide and show the wait window.

Hope that helps...

By Robin J Giltner - 11/8/2007

I'm trying to troubleshoot some problems we are having with Threads on forms that employ the waitwindow.  How might I go about turning off the fade in/out effect.

I couldn't find any property about it, or do I need to override one of the methods ?

Thanks

Robin Giltner

By StrataFrame Team - 11/8/2007

Are the problems you're having unexpected ThreadAbortExceptions?  Likely thrown within the WndProc for WM_PAINT messages?  If so, we've made changes to fix that very issue.  You should be able to go to the posted updates forum from the board home and find the latest version that will fix that very issue. 

Now, if that's not your issue, you might need to expound upon what it is.  At the moment, there's no way to prevent the wait window from using the fade effect... it always fades in/out. Ermm

By Robin J Giltner - 11/8/2007

Yeah, they are ThreadAbortExceptions. I'll give the latest release a try and see if it clears up.

Thanks.

Robin Giltner

By StrataFrame Team - 11/8/2007

Excellent... let me know one way or another.  Thanks.
By Alagarsamy Rajamannar - 11/17/2007

Hi,

 I am also doing the same and also tried the example from the help. I am not able to Show the Wait window.

 Having said that , Does WaitWindow behave differently when you work in a MDI window?

That is the only difference from what I am doing.

Indira

By Trent L. Taylor - 11/19/2007

Having said that , Does WaitWindow behave differently when you work in a MDI window?

No.  The wait window will behave the same in this environment as it does on any other form.  When you say that you are not able to show the Wait Window, are you receiving an exception?  Try placing a button on a form and calling the ShowWaitWindow to see if it appears.  If you are calling the WaitWindow on a separate thread then you will need to either invoke it on the main thread or ensure that it is called within the same thread in which you are working.  That would be the only thing I could think of that would cause it not to show.

MyWaitwindow.ShowWaitWindow("Title Text","Body Text",MicroFour.StrataFrame.Messaging.MessagingCardinalPosition.NorthEast)
By Alagarsamy Rajamannar - 11/19/2007

Hi,

 I sorted out the problem using BackGroundWorker component that is avaliable from .NET. I tried to use ThreadManager, but somehow I couldn't simulate the same way like BackgroundWoker component.

 It seems we need a separate thread. We cannot display WaitWindow on the same thread.

 Thanks

RajaSmile