-
Notifications
You must be signed in to change notification settings - Fork 3
/
myUpdateUIThread.rbbas
126 lines (111 loc) · 2.87 KB
/
myUpdateUIThread.rbbas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#tag Class
Protected Class myUpdateUIThread
Inherits SWORT_UpdateUIThread
#tag Event
Sub Run()
'When the thread runs, we set myPropertyToUpdate and when the UpdateUI event is run (by default every 200ms)
'we update the UI itself.
For i As Uint32 = 0 to 200000000
myPropertyToUpdate = "Count: " + Str(i)
Next
End Sub
#tag EndEvent
#tag Event
Sub UpdateUI()
Window1.myLabel.Text = myPropertyToUpdate
End Sub
#tag EndEvent
#tag Note, Name = Usage
There are multiple ways to use the SWORT_UpdateUIThread class.
You can subclass it, just as this example and add it to a window with a property.
You can also add the class to the window using drag and drop from the controls list.
It may be added as you wish.
Don't forget to set:
myUpdateUIThread.Period = 200 'is 200ms, or more
myUpdateUIThread.Mode = 2 'Use mode multiple for the timer to fire every "period" in ms.
You can enable or disable the timer by using myUpdateUIThread.Enabled = false 'or true
If you find bugs, have suggestions or other info please let me know by github here:
https://github.com/sworteu/Class_UpdateUIThread
#tag EndNote
#tag Property, Flags = &h0
#tag Note
This property will be set by the thread (Run event) itself and read from within the timer (UpdateUI event)
#tag EndNote
myPropertyToUpdate As String
#tag EndProperty
#tag ViewBehavior
#tag ViewProperty
Name="Enabled"
Group="Behavior"
Type="Boolean"
InheritedFrom="UpdateUIThread"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
Type="Integer"
InheritedFrom="Thread"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
Type="Integer"
InheritedFrom="Thread"
#tag EndViewProperty
#tag ViewProperty
Name="Mode"
Group="Behavior"
Type="Integer"
InheritedFrom="UpdateUIThread"
#tag EndViewProperty
#tag ViewProperty
Name="myPropertyToUpdate"
Group="Behavior"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
InheritedFrom="Thread"
#tag EndViewProperty
#tag ViewProperty
Name="Period"
Group="Behavior"
Type="Integer"
InheritedFrom="UpdateUIThread"
#tag EndViewProperty
#tag ViewProperty
Name="Priority"
Visible=true
Group="Behavior"
InitialValue="5"
Type="Integer"
InheritedFrom="Thread"
#tag EndViewProperty
#tag ViewProperty
Name="StackSize"
Visible=true
Group="Behavior"
InitialValue="0"
Type="Integer"
InheritedFrom="Thread"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
InheritedFrom="Thread"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
Type="Integer"
InheritedFrom="Thread"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass