-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodAsync.bas
More file actions
21 lines (20 loc) · 1022 Bytes
/
modAsync.bas
File metadata and controls
21 lines (20 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Option Explicit
'Ceci n'est pas utilisé dans le code, mais c'est fun de montrer comment faire du multi thread sur vba :P
'Spoiler: C'est pas stable en VBA xD
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function CreateThread Lib "Kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Private Declare Function TerminateThread Lib "Kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Private Declare Function CloseHandle Lib "Kernel32" (ByVal hObject As Long) As Long
Private hThread As Long, hThreadID As Long
Public Sub AsyncThread()
Sleep 2000
MsgBox "alkjsd"
hThread = 0
End Sub
Private Sub CreateAsync()
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf AsyncThread, ByVal 0&, ByVal 0&, hThreadID)
CloseHandle hThread
End Sub
Private Sub TerminateAsync()
If hThread <> 0 Then TerminateThread hThread, 0
End Sub