Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threads
#5
Example. Dialog starts other thread, and on timer notifies it to do some work.
Function dialog_and_thread
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dialog_and_thread" &dialog_and_thread)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040000 "" "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,SetTimer hDlg 1 500 0
,int- t_iid=qmitem("and_thread")
,
,case WM_TIMER
,sel wParam
,,case 1
,,;mac "and_thread" ;;bad
,,
,,;good
,,__Handle+ g_andThreadEvent; if(!g_andThreadEvent) g_andThreadEvent=CreateEvent(0 0 0 0)
,,SetEvent g_andThreadEvent
,,if(!IsThreadRunning(+t_iid)) mac("and_thread")
,,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Function and_thread
Code:
Copy      Help
if(getopt(nthreads)>1) ret
rep
,wait 0 H g_andThreadEvent
,out "and_thread works"


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)