Page 1 of 1

gtwvg + fivewin + multithread

Posted: Wed Aug 14, 2024 2:28 am
by JoséQuintas
I use GTWVG + Multithread + DBF + ADO/MySQL for a long time.
On multithread, DBFs are open/closed on each thread, can use CLOSE DATABASES to close DBFs on thread.

I test samples/guicui.prg

it crashes, or close more than one window.

With multithread things are easy.
Same sample using multithread, all works ok.

#include "FiveWin.ch"
#include "hbgtinfo.ch"
#include "std.ch"

REQUEST HB_GT_WVT

function Main()

local oWnd

DEFINE WINDOW oWnd TITLE "Main FWH Window"

ACTIVATE WINDOW oWnd ;
ON INIT hb_ThreadStart( { || Child( oWnd ) } );
ON CLICK hb_ThreadStart( { || Child( oWnd ) } )

return nil

function Child( oWnd )

local cFirst := Space( 10 ), cLast := Space( 10 ), GetList := {}

hb_gtReload( "WVT" )

HB_GtInfo( HB_GTI_CODEPAGE, "ES850C" )
Hb_GtInfo( HB_GTI_FONTNAME, 'Lucida Console')
hb_gtInfo( HB_GTI_WINTITLE, "opciones CONSOLA en Windows" )
HB_GtInfo( HB_GTI_CLOSABLE, .T. )

SetMode( 25, 80 )
SET COLOR TO "W+/B"
CLS

@ 1, 2 SAY "First:" GET cFirst
@ 3, 3 SAY "Last:" GET cLast // VALID ( ReadExit(), .T. )

READ

return nil

I would like to do the same, but call fivewin dialog from wvg.

Re: gtwvg + fivewin + multithread

Posted: Wed Aug 14, 2024 3:04 am
by JoséQuintas
forgot to add information:

I use harbour 3.2, mingw 14.2

compile the sample using:

hbmk2 test.prg fivewin.hbc -mt -w0

---fivewin.hbc---
incpaths=include

libpaths=lib
{mingw}libs=fivehg
{mingw}libs=fivehgc

and required lib names

Note: harbour wvg is not the same available on xharbour

Re: gtwvg + fivewin + multithread

Posted: Wed Aug 14, 2024 4:36 pm
by JoséQuintas
A simple test just now:

FUNCTION Main
hb_gtReload( "WVG" )
SetMode(33,100)
CLS
Inkey(0)
RETURN

This works using fivewin, but on normal use, this does not works.
There exists a init procedure/function on fivewin, like another libs, that "locks" previous proccess.
Is possible to call it on PRG source ?
hb_ThreadStart( { || TheInit(), dialogOther(), TheExit() } )

Re: gtwvg + fivewin + multithread

Posted: Sun Aug 18, 2024 2:19 pm
by JoséQuintas
Why I want multithread ?
To do anything as easy as this:

PROCEDURE Main

SET EXCLUSIVE OFF
hb_ThreadStart( { || Test(1) } )
hb_ThreadStart( { || Test(2) } )
hb_ThreadStart( { || Test(3) } )
hb_ThreadStart( { || Test(4) } )
hb_ThreadWaitForAll()

RETURN

FUNCTION Test( nModel )

hb_gtReload( "WVG" )
SetMode(25,80)
SetColor("W/B")
CLS
SET EXCLUSIVE OFF
USE Customer
Browse()
CLOSE DATABASES // open/close DBFs is per thread
(nModel)

RETURN Nil

No need to create classes for DBF, or invent different alias and controls for dbf.