Page 1 of 1

Harbour + MultiThread

PostPosted: Mon Sep 02, 2013 8:09 pm
by vilian
Hi,

I already run my function in a thread using:

hb_threadStart( @VerificaVersoes(),oEmpresa )

But when I close the program, always generates the error message below, Even having been completed the process carried out by VerificaVersoes()

Image

Re: Harbour + MultiThread

PostPosted: Tue Sep 03, 2013 1:10 pm
by vilian
I got a code posted in this forum to test Threads,

Code: Select all  Expand view
#include "Fivewin.ch"

 PROC Main()
    LOCAL aObj  := Array(1000000)
    LOCAL oDlg, oButton
    PUBLIC nDestroyed := 0
    DEFINE DIALOG oDlg SIZE 400, 500
    @ 11,  0 BUTTON    oButton     PROMPT "Start"    SIZE 80,  8 ACTION Button1_Click(oDlg)
    ACTIVATE DIALOG oDlg CENTER
 RETURN

 PROC Button1_Click(oDlg)
    LOCAL n        := 0
    LOCAL pMutex   := HB_MutexCreate()
    FOR n :=1 TO 10
       StartThread( "MyFuncForThreads", pMutex, oDlg, n )
    NEXT
    WaitForThreads()
 RETURN

 PROC MyFuncForThreads(pMutex,oDlg,n)
    LOCAL cTID
    HB_MutexLock(pMutex)
    oDlg:Say(n,0,"Thread ID" + lTrim(Str(GetThreadID())) + " system id: " + lTrim(Str(GetSystemThreadID())))
    HB_MutexUnlock(pMutex)
 RETURN


and even there the situation repeats itself. The program works perfectly, but when I close it the following message appears:

Image

Can anyone help me?

Re: Harbour + MultiThread

PostPosted: Wed Sep 04, 2013 1:20 pm
by vilian
+1

Re: Harbour + MultiThread

PostPosted: Thu Sep 05, 2013 10:51 am
by vilian
+1

Re: Harbour + MultiThread

PostPosted: Mon Sep 09, 2013 11:04 am
by vilian
`+1

Re: Harbour + MultiThread

PostPosted: Mon Sep 09, 2013 1:12 pm
by Antonio Linares
Vilian,

Your example is working fine here using FWH 13.07 and Harbour. I have used buildh.bat to build it simply changing:

echo %hdirl%\hbvmmt.lib + >> b32.bc

and

echo %bcdir%\lib\cw32mt.lib + >> b32.bc

I can provide you the EXE in case you want to run it