Hi could someone give me some help concerning CreateThread,this is my code im trying to create a thread which just popups a messagebox, the function call returns successful with a handle to a new thread but no messagebox appears. This is mysterious obviusly my code is wrong or something.
here is the offending code

section '.code' code readable writeable executable
start:
invoke CreateThread,NULL,NULL,ThreadProc,NULL,0,ThreadID
invoke CloseHandle,eax
Exit:
invoke ExitProcess,0


proc ThreadProc,Param:DWORD
enter
invoke MessageBox,NULL,Caption,AppName,MB_OK
return

any help would be appreciated.
thnx
Posted on 2003-01-14 11:20:24 by keyoke
You are just closing the thread too fast. Try putting "invoke Sleep,1000" after the CreateThread and you'll see what I mean.
Posted on 2003-01-14 11:59:45 by Tomasz Grysztar
Ha ha it works.....but it doesnt wait for user to click ok on msgbox :( how can i make it wait? if it had other code not msgbox in, would that code run to completion before the thread terminates?
Posted on 2003-01-14 12:06:16 by keyoke


invoke CreateThread,NULL,NULL,ThreadProc,NULL,0,ThreadID
invoke WaitForSingleObject,eax,-1
invoke ExitProcess,0
Posted on 2003-01-14 12:13:39 by Tomasz Grysztar
Aahh
thanks for the help :)
Posted on 2003-01-14 12:23:15 by keyoke
Shouldn't it be :



invoke MessageBox,NULL, addr Caption, addr AppName,MB_OK
[\CODE]

?
Posted on 2003-01-15 01:34:58 by Axial
What makes you say that?
Posted on 2003-01-16 06:46:37 by keyoke