I've created thread on PostInt() and want to terminate by OnClose().
METHOD PostInt() Class cScale_Dlg
LOCAL dwThreadID AS DWORD
...
...
CreateVOThread( NULL_PTR, 0, @Running_Digit(), PTR(_CAST, SELF), 0, dwThreadID )
RETURN
STATIC FUNCTION Running_Digit()
//Show Digit from Truck Scale using Ginny Serial Class
RETURN
METHOD OnClose() CLASS cScale_Dlg
// i want to terminate only the thread here ?
// and return to do other task in application
// i've used TermiateThread() but the application was terminated.
RETURN SUPER:OnClose(oEvent)
pls help,
Ping Pong
Michael
"Ping Pong" <ico...@hotmail.com> wrote in message
news:95d289de.04112...@posting.google.com...
John
"Ping Pong" <ico...@hotmail.com> schreef in bericht
news:95d289de.04112...@posting.google.com...
> METHOD PostInt() Class cScale_Dlg
> LOCAL dwThreadID AS DWORD
> ...
> ...
> CreateVOThread( NULL_PTR, 0, @Running_Digit(), PTR(_CAST, SELF), 0, dwThreadID )
> RETURN
This is incorrect and dangerous:
1. You are passing a pointer to SELF. That address may and will certainly
move when the GC becomes actibe
2. You should pass dwThreadid by reference. That will return the ID of the
new thread.
CreateVOThread returns a Thread Handle. You can use this handle and call
TerminateThread() to terminate the thread.
--
Robert van der Hulst
AKA Mr. Data
Vo2Jet & Vo2Ado Support
VO Development Team
www.sas-software.nl
mrdata...@sas-software.com
i've changed code as u suggested and it's work fine. Thanks for all of
replying messages.
changed code to,
1.pass dwThreadid by reference
-->CreateVOThread( NULL_PTR, 0, @Running_Digit(), PTR(_CAST, SELF), 0,
@dwThreadID )
2.CreateVOThread returns a Thread Handle. and this handle and call
TerminateThread() to terminate the thread.
-->TerminateThread( SELF:ptrSerialThread, 0 )
i've defined SELF:ptrSerialThread := CreateVOThread( NULL_PTR, 0,
@Running_Digit(), PTR(_CAST, SELF), 0, @dwThreadID ) at PostInt().
Robert van der Hulst <mrdata...@sas-software.com> wrote in message news:<1818130158.2...@sas-software.nl>...
Although TerminateThread will kill the thread, it really isn't the Microsoft
recommended way to do so in any programming language with any version of
Windows. I agree with Michael that the best way is to have the main thread
tell the worker thread to end itself and then wait until that happens before
exiting the app.
--
Ginny
"Ping Pong" <ico...@hotmail.com> wrote in message
news:95d289de.04112...@posting.google.com...