UserInterfaceUpdate Issue...

I’m having an issue using the new UserIntefaceUpdate process. The goal of the thread is to change a text field and wait 2 seconds.

My thread Run event:

[b]Dim theEnd, wait15 as Integer

'Set up a 2 second delay
theEnd = System.Ticks + 120

While System.Ticks < theEnd

'Set up a 1/4 second delay
wait15 = System.Ticks + 15

'Delay a 1/4 second
While System.Ticks < wait15
Wend

’ Update Window Fields
Me.AddUserInterfaceUpdate(“LblStatus”:gtheUIDelayLblStatus)
Me.AddUserInterfaceUpdate(“dlStatus”:gtheUIDelaydlStatus)

Wend[/b]

I set the global variables (gtheUIDelayLblStatus, gtheUIDelaydlStatus) prior to thread start.

The UserInterfaceUpdate event:

[b]For Each arg As Dictionary In data
If arg.HasKey(“LblStatus”) Then
LblStatus.Value = arg.Value(“LblStatus”).StringValue
End If

If arg.HasKey(“dlStatus”) then
dlStatus.Value = arg.Value(“dlStatus”).StringValue
End If
Next[/b]

The UserInterfaceUpdate event is never triggered during the 2 sec delay.

Any thoughts?

  1. Why not just say me.sleep (2000)

  2. You’re not calling AddUserInterfaceUpdate until after the two second delay completes.

[quote=488330:@Ross Carothers]'Delay a 1/4 second
While System.Ticks < wait15
Wend
[/quote]
Your tight loop is hogging the cpu and not allowing time for the update to happen. Use Sleep(500) instead.

Thanks for the comments.

@Tim S. - I think the while loop is running for 2 secs and the AddUserInterfaceUpdate within the loop is happening quite a lot. This is why I put another 1/4 second delay within the loop itself.

@Tims - I replaced the 1/4 second delay with the sleep command without success.

Additionally, I forgot to mention, the USerInterfaceUpdate event never fires, but the AddUserInterfaceUpdate commands are run.

This is very odd to me.

I put my above code into the UI Update example and it ran correctly. Weird that it doesn’t; work in my program.

In my actual program, the thread call is within nested methods - wonder if this is an issue

In most of my apps, the whole point of using threads in the first place is to be able to implement delays via Sleep without blocking the UI with loops.