05-22-2013 10:02 AM
I am trying to display timer that would continuously update on a user dialog box (It would start when a button was clicked). What would be the best way to do this?
Drew
05-23-2013 12:29 PM
Hi Drew,
What else is going on while the user is watching the timer? What is the user waiting on? Are you running a VBScript loop of some sort?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-23-2013 02:20 PM
Hi Brad,
Nothing is going on in the background while the dialog box is open. The dialog box has some basic test information fields which get fed to a data processing script via "ScriptInclude" when the "Continue" button is clicked. The user must wait at least 3 min before beginning the next test so I would like to be able to show a timer for that in the dialog box.
Drew
05-23-2013 05:26 PM
Hi Drew,
Then I would create a textbox control on the dialog and simply update its ControlName.Text=NewValue every second. You can use the Pause(1) command in a FOR loop to regulate the update frequency to once per second. This loop will have to be housed in a callback, probably the click callback of the "Continue" button, after you've sent the info to the data processing script.
Is the data processing script running in DIAdem while the SUDialog is counting down the wait time? That would constitute the sort of loop I was asking about...
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-24-2013 08:10 AM
Hi Brad,
Thanks for the help. I tried the loop you recommended but it wouldn't update the control in the dialog box, instead it froze and forced me to quit DIAdem. Currently, nothing is running in the background as I am still in the development stage.
Drew
05-24-2013 12:07 PM
Hi Drew,
I'm sorry, I didn't test that idea. Now that I have, I see that the textbox only updates after the ButtonClick callback as completed, so instead of seeing the textbox count up from 1 to 10 in my code, I only see it show 10 after 10 seconds have passed. Before that it does look like DIAdem is hung, but it wasn't in my case.
OK, so that means you need to pop up a new progress dialog. You could create a second dialog defined in that same *.SUD file or create a new *.SUD file with a progress indicator on it, or you could use DIAdem's native non-modal dialog with MsgBoxDisp(). I did test this code 🙂
Sub Button1_EventClick(ByRef This) 'Created Event Handler Dim i, iMax, Msg iMax = 10 FOR i = 1 TO iMax Call Pause(1) Msg = "Second " & i & " of " & iMax & " ..." Call MsgBoxDisp(Msg, "MB_NOBUTTON", "MsgTypeNote", 0, 0, 1) NEXT ' i Call MsgBoxCancel End Sub
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-08-2021 10:06 AM - edited 10-08-2021 10:07 AM
Hello,
i get you that during the cycle, diadem looks like frozen and wont let user do do anything, until the cycle with pause is done.
I have a question, i want to show dialog with setting to let user change something. but if he doesnt do anything, i want after one minute since the dialog started, to shut it down and let the program continue.
As there is problem with the sync behaviour of runnig code, is there some solution for me on the callback of dialog "_EventInitFinalize(ByRef This)" to run some async code in the background with 1 second cycle 60 times? some kind of background thread..