Hi
I am new in programming with Powerbasic and i have a little problem
with Thread programming.
the command:
THREAD CREATE MyThreadFunction(1) TO hThread???
returns me in hThread always a 0 but the Thread is runing.
So that i not can not suspend,resume or change Priority of the thread
Can anybody tell me what i make wrong in the following code.
For help would be I most grateful.
With kind regards
Andreas
I am new in programming with Powerbasic and i have a little problem
with Thread programming.
the command:
THREAD CREATE MyThreadFunction(1) TO hThread???
returns me in hThread always a 0 but the Thread is runing.
So that i not can not suspend,resume or change Priority of the thread
Can anybody tell me what i make wrong in the following code.
For help would be I most grateful.
With kind regards
Andreas
Code:
Code:
[SIZE=2]#COMPILE EXE[/SIZE] [SIZE=2]#DIM ALL[/SIZE] [SIZE=2]#INCLUDE "Win32API.inc"[/SIZE] [SIZE=2]%IDOK = 1[/SIZE] [SIZE=2]%IDCANCEL = 2[/SIZE] [SIZE=2]%IDTEXT = 100[/SIZE] [SIZE=2]%BN_CLICKED = 0[/SIZE] [SIZE=2]%BS_DEFAULT = 1[/SIZE] [SIZE=2]%MF_ENABLED = 0[/SIZE] [SIZE=2]%WM_COMMAND = &H111[/SIZE] [SIZE=2]%ID_OPEN = 401[/SIZE] [SIZE=2]%ID_EXIT = 402[/SIZE] [SIZE=2]%ID_OPTION1 = 403[/SIZE] [SIZE=2]%ID_OPTION2 = 404[/SIZE] [SIZE=2]%ID_HELP = 405[/SIZE] [SIZE=2]%ID_ABOUT = 406[/SIZE] [SIZE=2]FUNCTION PBMAIN () AS LONG[/SIZE] [SIZE=2]GLOBAL HWindow AS LONG[/SIZE] [SIZE=2]GLOBAL lResult AS LONG[/SIZE] [SIZE=2]GLOBAL hThread AS DWORD[/SIZE] [SIZE=2]DIALOG NEW 0, "Thread Handle Test", ,, 350, 250, %WS_SYSMENU OR %WS_CAPTION TO HWindow[/SIZE] [SIZE=2]CONTROL ADD STATUSBAR, HWindow, 500, "",0,0,0,0,%CCS_TOP[/SIZE] [SIZE=2]STATUSBAR SET PARTS HWindow,500, 150,150,99999[/SIZE] [SIZE=2]'--------------------------------------------------------------------------[/SIZE] [SIZE=2]THREAD CREATE MyThreadFunction(1) TO hThread???[/SIZE] [SIZE=2]STATUSBAR SET TEXT HWindow, 500, 2, 0, "Thread Handle : " + STR$(hThread)[/SIZE] [SIZE=2]'--------------------------------------------------------------------------[/SIZE] [SIZE=2]DIALOG SHOW MODAL HWindow , CALL CallBackProc TO lResult[/SIZE] [SIZE=2]END FUNCTION[/SIZE] [SIZE=2]FUNCTION MyThreadFunction(BYVAL x AS LONG) AS LONG[/SIZE] [SIZE=2]LOCAL tick AS DWORD[/SIZE] [SIZE=2]LOCAL a AS DWORD[/SIZE] [SIZE=2]DO UNTIL a = 1000000000[/SIZE] [SIZE=2]a = a + 1[/SIZE] [SIZE=2]SLEEP 1[/SIZE] [SIZE=2]STATUSBAR SET TEXT HWindow, 500, 1, 0, "Thread Output : " + STR$(a)[/SIZE] [SIZE=2]LOOP[/SIZE] [SIZE=2]END FUNCTION[/SIZE] [SIZE=2]CALLBACK FUNCTION CallBackProc()[/SIZE] [SIZE=2]IF CB.MSG = %WM_COMMAND THEN[/SIZE] [SIZE=2]IF CB.CTL => %ID_OPEN AND CB.CTL <= %ID_ABOUT THEN[/SIZE] [SIZE=2]FUNCTION = 1[/SIZE] [SIZE=2]END IF[/SIZE] [SIZE=2]END IF[/SIZE] [SIZE=2]END FUNCTION[/SIZE]
Comment