-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySynchronousSleep.bas
More file actions
60 lines (39 loc) · 1.33 KB
/
Copy pathMySynchronousSleep.bas
File metadata and controls
60 lines (39 loc) · 1.33 KB
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
B4A=true
Group=Classes
ModulesStructureVersion=1
Type=Class
Version=12.5
@EndOfDesignText@
'
'This class is a subclass of the MyCommon one
'
'It should not directly be used as-is, use it through
'the MyCommon class only
'
Sub Class_Globals
'To ensure correct running functions order
Private SynchronousSleepThread As Thread
End Sub
'Initializes the object
'You can add parameters to this method if needed
Public Sub Initialize
'To ensure correct running functions order
SynchronousSleepThread.Initialize("SynchronousSleepThread")
End Sub
Private Sub SynchronousSleepThread_Ended(Failed As Boolean, ErrorIfAny As String)
End Sub
Public Sub SynchronousSleep_Start(Milliseconds As Int, OriginClassCaller As Object, SubName As String)
SynchronousSleepThread.Start(Me, "SynchronousSleep_Sleep_Thread", Array(Milliseconds, Me))
Wait For SynchronousSleep_Completed
CallSubDelayed(OriginClassCaller, "SynchronousSleep_"&SubName&"_Completed")
End Sub
Private Sub SynchronousSleep_Sleep_Thread(Milliseconds As Int, ThisClassCaller As Object)
SleepForNewThreads(Milliseconds)
CallSubDelayed(ThisClassCaller, "SynchronousSleep_Completed")
End Sub
Private Sub SleepForNewThreads(Milliseconds As Int)
Dim DueTime As Long = DateTime.Now + Milliseconds
Do While DateTime.Now < DueTime
SynchronousSleepThread.Sleep(20)
Loop
End Sub