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

Problems with threads when the Application lost focus an gets reactivated

12 views
Skip to first unread message

Georg Tsakumagos

unread,
Oct 11, 2002, 10:12:01 AM10/11/02
to
I've Problem with a little sample Dialog i've written. This dialog is
an chat for my clients, It has an MLE for postings and a SLE for own
postings plus a send button. My dialog uses a socketengine wich could
start an thread for each managed socket. Everything works fine! But if
i activate another application and switch back to the dialog my
application hangs. I've build in a logging to see wich instruction was
the last. The Thread don't come back from Sleep. It seemed that this
isn't the Problem. But my Application don't get painted. It get
blocked! From what? The Thread isn't active!

Her the Thread Func:

function ThreadLoop( nThreadInfoId as ptr ) as dword _wincall
local oInfo as ADESocketInfoSemaphore
local nRetVal := 0 as dword

if .not. nThreadInfoId = NULL_PTR
oInfo := object( _cast, nThreadInfoId )

if .not. oInfo == NULL_OBJECT
if .not. oInfo:Connection == NULL_OBJECT
do while oInfo:Connection:Execute( oInfo )
_FuncLOG( "SocketThread Pre Sleep" )
Sleep( oInfo:ThreadTimeOut )
_FuncLOG( "SocketThread Post Sleep" )
end do

_FuncLOG( "SocketThread End" )
end if
end if
end if
return nRetVal

Here the Creation of the Thread:

method InitConnectionThread( poItem, poInfo, nTimeOut )class
ADESocketEngine
local lRetVal := false as logic
local oItem as ADESocketConnection
local oInfo as ADESocketInfoSemaphore
local pInfoPtr as ptr

Default( @nTimeOut, self:ThreadTimeOut )

oItem := poItem
oInfo := poInfo

if .not. oItem == NULL_OBJECT
if .not. oInfo == NULL_OBJECT
pInfoPtr := ptr( _cast, oInfo )
oInfo:ThreadTimeOut := nTimeOut
oInfo:ptrThread := CreateVOThread( NULL, ; // No Security
0, ; // Default Stack size
@ThreadLoop(), ; // Entry Point
pInfoPtr, ; // Socket Info
CREATE_SUSPENDED, ; // Do not run immediately
ptr( _cast, @oInfo:ThreadID ) ) // Receives thread Id

if .not. oInfo:ptrThread == NULL
SetThreadPriority( oInfo:ptrThread, THREAD_PRIORITY_LOWEST )
ResumeThread( oInfo:ptrThread )
end if

lRetVal := true
end if
end if
return lRetVal

0 new messages