Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help me for multithread in Vo 2.5

8 views
Skip to first unread message

dpl...@my-deja.com

unread,
Dec 6, 2000, 3:00:00 AM12/6/00
to
Napoli chiama............... Il Mondo risponde..........

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.

Frank Seidel

unread,
Dec 6, 2000, 3:00:00 AM12/6/00
to
Luigi,

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 Caughey

unread,
Dec 6, 2000, 3:00:00 AM12/6/00
to
In addition to the good replies you've already received, you'll want to set
the priority of a thread like this very low. And a timer would probably be a
better way to accomplish what you want that a separate thread anyway.

Ginny

<dpl...@my-deja.com> wrote in message news:90l96c$qp$1...@nnrp1.deja.com...

Stephen Quinn

unread,
Dec 6, 2000, 8:43:31 AM12/6/00
to

The GUI classes are NOT threadsafe, it says so in the docs.

--
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.


0 new messages