Hi guys,
I have an Activity (called "DashBoard") and a Class (called "appClass").
In appClass there is resumable sub called "FileImport": it processes a CSV file.
During the file processing I call (by Callsub statement) the "ShowStatus" sub that displays a string in a label (lblStatus).
If don't put the DOEVENTS command inside the "ShowStatus", the label is not updated.
Here's the relevant code, the process starts clicking a button (BTN_Click):
During debugging, if I put a breakpoint in ShowStatus sub, the label is updated...
I know DoEvents should not be used, but how can I achieve what I need ? Thanks in advance
PS. Tried also CallSubDelayed3 (I don't think is relevant), with no luck...
I have an Activity (called "DashBoard") and a Class (called "appClass").
In appClass there is resumable sub called "FileImport": it processes a CSV file.
During the file processing I call (by Callsub statement) the "ShowStatus" sub that displays a string in a label (lblStatus).
If don't put the DOEVENTS command inside the "ShowStatus", the label is not updated.
Here's the relevant code, the process starts clicking a button (BTN_Click):
DashBoard:
Sub BTN_Click
Dim AC As App_Class: AC.Initialize
wait for (AC.FileImport(Me)) complete (success As Boolean)
End Sub
Sub ShowStatus(Msg As String,RowNum As Int)
If RowNum>0 Then
lblStatus.Text="Processing row: " & RowNum
else if Msg.Length>0 Then
lblStatus.Text=Msg
Else
lblStatus.Text=""
End If
' lblStatus.Invalidate ' <- NOT WORKING
' Sleep(0) ' <- NOT WORKING
DoEvents ' WORKS !!!
End Sub
AppClass:
Sub Class_Globals
Dim DummyAct As Activity
End Sub
...
Sub DataImport(Caller As Object) As ResumableSub
...
Dim NRows as int=0
Do While (...)
...
NRows=NRows+1
if NRows mod 100=0 Then ' Update the Status only each 100 rows
If SubExists(Caller,"ShowStatus") Then CallSub3(Caller,"ShowStatus","",NRows)
End If
Loop
If SubExists(Caller,"ShowStatus") Then CallSub3(Caller,"ShowStatus","",0) ' Clear Status
Return true
End Sub
During debugging, if I put a breakpoint in ShowStatus sub, the label is updated...
I know DoEvents should not be used, but how can I achieve what I need ? Thanks in advance
PS. Tried also CallSubDelayed3 (I don't think is relevant), with no luck...