Hi to all.
I feel really very depressed, in I as am not able to understand
because the Mutithread doesn't work me, good it still work me for any
seconds:
My system is the following:
Windows 2000 Prof.
Visual Objects 2.5B1
The code is the following
METHOD PostInit(oWindow, iCtlID, oServer, uExtra) CLASS MyWindow
local dwId as dword
Self:hHandle:=CreateVOThread(NULL,0,@ThreadProc(),ptr
(_CAST,self),0,@dwID)
self:dwThread := dwId
//
return( NIL )
static function ThreadProc( dwParam ) as short
local oMyObj as object
local cTime as string
oMyObj := object(_CAST, dwParam)
cTime := Time()
do while !( oMyObj:Abort )
// ad esempio
oMyObj:Caption := elaptime(cTime, Time())
enddo
ExitVoThread( 0 )
return( 0 )
I have used the library of Fabrice Foray also, using the
Fabthread class, and FabThreadPushButton, the result is that it after
any seconds jams the application however.
thank you for all, help me
Sent via Deja.com http://www.deja.com/
Before you buy.
there are some faults in your code:
the prototype of a thread-func is:
FUNCTION ThreadFunc(ptrParam AS PTR) AS DWORD PASCAL. so you should change
your func accordingly.
Next, passing a pointer to a VO-Object via PTR(_CAST, SELF), you'll have the
best chances to crash your app if the GC kicks in and moves your object, use
SELF:ptrSelfPtr for all objects inheriting from EventContext (all windows)
instead.
Then, as Sabo said on DevCon, CreateVOThread/ExitVOThread isn't neccessary
anymore (since 2.5 if I remember correctly). Simply use CreateThread() to
start the thread and RETURN dwRetValue to end it.
And finally, you may get in trouble if you'r not closing the thread handle
via CloseHandle(), e.g when closing the window - you will need to issue some
process synchronisation in your thread and Window:Close(), i.e. waiting for
the thread to terminate before closing it's handle and forcing the thread to
terminate if your window closes, take a look at WaitForSingleObject().
Well, MultiThreading really isn't trivial <g>.
Cheers
Frank
Ginny
<dpl...@my-deja.com> wrote in message news:90l96c$qp$1...@nnrp1.deja.com...
--
HTH
Steve Quinn
http://www.brutecom.com.au
If you're too open minded, your brains will fall out.
Age is a very high price to pay for maturity.
Artificial intelligence is no match for natural stupidity.