#COMPILE EXE
#DIM ALL
GLOBAL hThread AS LONG
THREAD FUNCTION mThread_Start(BYVAL mWnd AS DWORD) AS LONG
LOCAL lResult AS LONG
SLEEP 3000
MSGBOX "Привет из потока"
THREAD CLOSE hThread TO lResult
END FUNCTION
FUNCTION PBMAIN () AS LONG
THREAD CREATE mThread_Start(0) TO hThread
SLEEP 3000
MSGBOX "Привет"
SLEEP 5000
END FUNCTION
HouseMD писал(а):если я правильно понял вопрос - то в пб есть встроенная функция THREAD CREATE
#Compile DLL
#Dim All
#Include Once "Win32API.inc"
Global ghInstance As Dword
Global hThread As Dword
Global gFileName As String
Global gFileContent As String
Global gCallBackFunct As Dword
Declare Function SaveFileThread Alias "SaveFileThread" (ByVal FileName As String, ByVal FileContent As String, ByVal CallBackFunct As Dword) As Dword
Declare Thread Function mThread_Save(ByVal mWnd As Dword) As Dword
Declare Sub CallBackProc()
'-------------------------------------------------------------------------------
' Main DLL entry point called by Windows...
'
Function LibMain (ByVal hInstance As Long, _
ByVal fwdReason As Long, _
ByVal lpvReserved As Long) As Long
Select Case fwdReason
Case %DLL_PROCESS_ATTACH
ghInstance = hInstance
Function = 1 'success!
Case %DLL_PROCESS_DETACH
Function = 1 'success!
Case %DLL_THREAD_ATTACH
Function = 1 'success!
Case %DLL_THREAD_DETACH
Function = 1 'success!
End Select
End Function
'-------------------------------------------------------------------------------
Thread Function mThread_Save(ByVal mWnd As Dword) As Dword
Local lResult As Dword
Local f As Dword
f=FreeFile
Open gFileName For Binary As f
Put$ f,gFileContent
Close f
gFileContent=""
Thread Close hThread To lResult
Call Dword gCallBackFunct Using CallBackProc 'Вызов функции в VB коде для оповещении о конце записи файла
End Function
Function SaveFileThread Alias "SaveFileThread" (ByVal FileName As String, ByVal FileContent As String, ByVal CallBackFunct As Dword) Export As Dword
gFileName=FileName
gFileContent=FileContent
gCallBackFunct=CallBackFunct
Thread Create mThread_Save(0) To hThread
FileContent=""
End Function
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 9