[quote=407097:@Beatrix Willius]Thead/timer combos are sometimes very stubborn.
Does the task example work for you? I think it’s rather convoluted but it works.[/quote]
I use that for another app and it works. Not as granularly as on Linux and macOS, but it’s at least fast enough for a once-a-second update in that case.
The Timer - LoadingArchives is False once all of the records have bee progressed:
If LoadingArchives Then
WMain.ccMainTools1.prArchiveLoad.Value = ArLoadCnt
WMain.ccMainTools1.prArchiveLoad.Invalidate
WMain.ccMainTools1.lLoadingArchives.Text = kLoadingArchives + " (" + Format(ArLoadCnt, "#,") + " of " + Format(arcCount, "#,") + ")"
Else // load completed
WMain.ccMainTools1.lLoadingArchives.Invalidate
WMain.ccMainTools1.lLoadingArchives.Visible = False
WMain.ccMainTools1.prArchiveLoad.Visible = False
WMain.ccMainTools1.cvToolButton(7).Enabled = True
WMain.ccMainTools1.cvToolButton(1).Backdrop = Restore32x32
WMain.ccMainTools1.lRestore.TextColor = &c2F2F2F00
WMain.ccMainTools1.cvToolButton(8).Enabled = True
WMain.ccMainTools1.cvToolButton(2).Backdrop = Verify32x32
WMain.ccMainTools1.lVerify.TextColor = &c2F2F2F00
Me.Mode = 0
End If
The method called from the thread. theShell is setup at the start of the method, but is not part of the loop.
If arcCount <> 0 Then
z = arcCount
// loop through all of the archives getting the details
Startloop = Ticks
WMain.tmUpdateArLoadCount.Mode = 2
for ArLoadCnt = 0 to arcCount - 1
t = Ticks
TimedOut = False
Finished = False
theResult = ""
Call ReplaceLineEndings(theShell.ReadAll, EndOfLine)
cmd = "show -m archives """ + arcIDs(ArLoadCnt) + """"
theShell.WriteLine cmd
Do
theShell.Poll
Finished = InStr(theShell.Result, "input:") <> 0
TimedOut = InStr(theResult, "ERROR: Operation timed out") <> 0
Loop Until Finished or TimedOut
theResult = ReplaceAllB(ReplaceAllB(ReplaceAllB(ReplaceLineEndings(theShell.ReadAll, EndOfLine), "input:", ""), EndOfLine, ""), cmd, "")
// show -m archives 472de02107bb
// ('Nov 04 15:10:54 2007', 'Bob', 'Offsite Backups', 'Full', ['A00007L2'], [13711], 'admin') If theResult <> "" Then
If TimedOut Then
Dim md As New MessageDialog
md.Message = kServerCommProblemMsg
md.Explanation = kServerCommProblemExp1 + BSServer + kServerCommProblemExp2 + Str(LongTimeout) + kServerCommProblemExp3
md.ActionButton.Caption = kOK
Call md.ShowModal
theShell.WriteLine "exit"
theShell.Close
theShell = Nil
Return
ElseIf CancelArchiveLoad Then
Redim MyArchives(-1)
theShell.WriteLine "exit"
theShell.Close
theShell = Nil
Return
End If
archiveList.Append arcIDs(ArLoadCnt) + ": " + theResult
End If
Next
EndLoop = ticks
LoadingArchives = False
For x = 0 To tickmarks.Ubound
Next
GenArchives archiveList
End If
Again, this is very smooth under both Linux and macOS.
I’ll think through that.
As a second thought, would using the Xojo.Core.Timer.CallLater() be a saner option for something like this?