Why Doesnt This Work Again?
-
This doesnt work the way I want it to. Whats happening. :((
Public Sub DoSomeWork()
'This is Pseudo-Code
ChangeImageBackColor(RED)
DoTimeConsumingWork()
ChangeImageBackColor(GREEN)
End SubFor Some reason, I never see the Image change its Color? I forget why this doesnt work. Cheers Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
This doesnt work the way I want it to. Whats happening. :((
Public Sub DoSomeWork()
'This is Pseudo-Code
ChangeImageBackColor(RED)
DoTimeConsumingWork()
ChangeImageBackColor(GREEN)
End SubFor Some reason, I never see the Image change its Color? I forget why this doesnt work. Cheers Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
The good old DoEvents
Public Sub DoSomeWork() 'This is also Pseudo-Code ChangeImageBackColor(RED) DoEvents DoTimeConsumingWork() ChangeImageBackColor(GREEN) End Sub
or in VB.NET
Public Sub DoSomeWork() 'This is also Pseudo-Code ChangeImageBackColor(RED) System.Windows.Forms.Application.DoEvents() DoTimeConsumingWork() ChangeImageBackColor(GREEN) End Sub
-
The good old DoEvents
Public Sub DoSomeWork() 'This is also Pseudo-Code ChangeImageBackColor(RED) DoEvents DoTimeConsumingWork() ChangeImageBackColor(GREEN) End Sub
or in VB.NET
Public Sub DoSomeWork() 'This is also Pseudo-Code ChangeImageBackColor(RED) System.Windows.Forms.Application.DoEvents() DoTimeConsumingWork() ChangeImageBackColor(GREEN) End Sub
Okay, I still dont get the results I want. The DoTimeConsumingWork() function is in a DLL I programmed in C++. I am using the ImageCOlor() as a busy indicator. Using Doevents as you have showed me does not work the way I need it to, which is "Show me when you start the function" - "Show me when you finish the function" Also I should note that this is VBA code Im writing in an excel spreadsheet. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
Okay, I still dont get the results I want. The DoTimeConsumingWork() function is in a DLL I programmed in C++. I am using the ImageCOlor() as a busy indicator. Using Doevents as you have showed me does not work the way I need it to, which is "Show me when you start the function" - "Show me when you finish the function" Also I should note that this is VBA code Im writing in an excel spreadsheet. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
This is a cheap example for Excel VBA but even works without DoEvents. Strange...
Sub Process() Me.Cells(1, 1).Interior.Color = vbRed DoSomeWork Me.Cells(1, 1).Interior.Color = vbGreen End Sub Sub DoSomeWork() Dim s As String, n As Long For n = 0 To 13000 s = s + " " Next End Sub
Got no idea then. Sorry! -
The good old DoEvents
Public Sub DoSomeWork() 'This is also Pseudo-Code ChangeImageBackColor(RED) DoEvents DoTimeConsumingWork() ChangeImageBackColor(GREEN) End Sub
or in VB.NET
Public Sub DoSomeWork() 'This is also Pseudo-Code ChangeImageBackColor(RED) System.Windows.Forms.Application.DoEvents() DoTimeConsumingWork() ChangeImageBackColor(GREEN) End Sub
Do Events is evil... In general I have found that it cause more race conditions than anything. Try: ImageObject.Refresh()