Code: Select all
#include once "vbcompat.bi"
type _
ClockThreadContext
as any ptr _
mutex
as boolean _
isRunning
end type
declare sub DISPLAYTIME ( byval as ClockThreadContext ptr )
declare SUB INPUTSCREEN ()
'Dim Mutex As Any Ptr 'create Mutex as a pointer
'Mutex = MutexCreate()
var _
context => type <ClockThreadContext>( _
mutexCreate(), _
true )
var _
hThread = ThreadCreate( _
cptr( sub( byval as any ptr ), @DisplayTime ), _
@context )
'=======================================================================
SUB INPUTSCREEN()
static as integer count
'=======================================================================
locate 3, 1
? "Getting input: " & count
count +=> 1
END SUB
'=======================================================================
SUB DISPLAYTIME ( _
byval c As ClockThreadContext ptr )
'=======================================================================
Do while( c->isRunning )
MutexLock ( c->mutex )
locate 9,8: print Format(Now, "hh:mm:ss")
'If Is_Running=0 Then Exit Sub
MutexUnLock (c->mutex )
Sleep 100, 1
Loop
END SUB
dim as boolean _
done
locate , , 0
do while( not done )
mutexLock( context.mutex )
locate 1, 1
? "Display, update, whatever"
inputScreen()
mutexUnlock( context.mutex )
if( len( inkey() ) ) then
done => true
end if
sleep( 1, 1 )
loop
'BELOW AT END OF PROGRAM:
context.isRunning => false
ThreadWait hThread
'WRITETOFILE
'END
mutexDestroy( context.mutex )