I found a way how to create thread in windows:
======== thread.bmx File 1 of 2 =============
======= win32thread.bmx File 2 of 2 =======
======== thread.bmx File 1 of 2 =============
Strict Import "win32thread.bmx" Global count:Int = 0 Local funcPtr:Int() = foo Local funcPtr2:Int() = foo2 Local h1:Int = CreateThread(Null,0,funcPtr) Local h2:Int = CreateThread(Null, 0,funcPtr2) While True If count = 10 TerminateThread(h1) Print "" Print "Thread 1 terminates..." Print "" count = 0 End If Wend Function foo() While True Print "Thread Nr. 1 counts: " + count count = count + 1 Delay 750 Wend End Function Function foo2() While True Print "Hallo, I'm thread number 2" Delay 500 Wend End Function
======= win32thread.bmx File 2 of 2 =======
Extern "Win32" Rem The CreateThread function creates a thread to execute within the virtual address space of the calling process. HANDLE CreateThread( LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId ); Return Values If the function succeeds, the return value is a handle to the new thread. If the function fails, the return value is NULL. End Rem Function CreateThread:Int (lpThreadAttributes:Byte Ptr,.. 'Pointer to a SECURITY_ATTRIBUTES structure. dwStackSize:Int,.. 'Initial size of the stack, in bytes. pStartAddress:Int(), .. 'Pointer To the application-defined Function To be executed by the thread And represents the starting address of the thread. lpParameter:Byte Ptr=Null,.. ' Pointer to a variable to be passed to the thread. dwCreationFlags:Int=0,.. 'Flags that control the creation of the thread. pThreadId:Int Ptr=Null) 'Pointer to a variable that receives the thread identifier. If this parameter is NULL, the thread identifier is not returned. Rem The TerminateThread function terminates a thread. BOOL TerminateThread( HANDLE hThread, DWORD dwExitCode ); hThread [in, out] Handle to the thread to terminate. dwExitCode [in] Exit code for the thread. Use the GetExitCodeThread function to retrieve a thread's exit value. Return Values If the function succeeds, the return value is nonzero. End Rem Function TerminateThread:Int (hThread:Int, dwExitCode:Int =0) End Extern