Platforms to show: All Mac Windows Linux Cross-Platform
/Util/Test CallDelegateOnMainThreadMBS
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Test CallDelegateOnMainThreadMBS
This example is the version from Thu, 24th Jul 2019.
Project "Test CallDelegateOnMainThreadMBS.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control TestButton Inherits PushButton
ControlInstance TestButton Inherits PushButton
EventHandler Sub Action()
Me.Enabled = False
bar.Maximum = 0
bar.Value = 0
bar.Visible = true
Thread1.run
End EventHandler
End Control
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run()
CallDelegateOnMainThreadMBS AddressOf AddRow, "Start"
Me.Sleep 500
For i As Integer = 1 To 10
CallDelegateOnMainThreadMBS AddressOf setProgress, i
CallDelegateOnMainThreadMBS AddressOf AddRow, "Step "+Str(i)
Me.Sleep 500
Next
CallDelegateOnMainThreadMBS AddressOf AddRow, "Done"
CallDelegateOnMainThreadMBS AddressOf finish
End EventHandler
End Control
Control bar Inherits ProgressBar
ControlInstance bar Inherits ProgressBar
End Control
Sub AddRow(s as string)
listbox1.AddRow s
End Sub
Sub Finish()
bar.Visible = False
testbutton.Enabled = True
End Sub
Sub SetProgress(n as integer)
bar.Maximum = 10
bar.Value = n
End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
See also:
The items on this page are in the following plugins: MBS Util Plugin.