FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Thread on FWH
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Thread on FWH
Posted: Mon Feb 16, 2009 01:11 PM
Hello Mr.Antonio,

In this topic:

viewtopic.php?f=3&t=10439

I read is not possible use mult-thread in FWH, but you ask for what
need this...

Please, see the code below:

Code (fw): Select all Collapse
//------------------------------------------------------------------------------
Function Test()

MsgProgres('Executing SQL query...','Wait, please...',{|| Query() },.F.)

SELECT TEMP
GO TOP
BROWSE()

return
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
FUNCTION Query()
cSqlComand = "SELECT ID,Name,City,Country,Phone  FROM tbCustomers ORDER BY Name"
USE 'tbCustomers' AS cSqlComand ALIAS 'TEMP' VIA 'MySQL'
RETURN
//---------------------------------------------------------------------------------


//---------------------------------------------------------------------------------
FUNCTION MsgProgres(cCaption,cTitle,bAction)

LOCAL oDlg
LOCAL nWidth:=0

PRIVATE nContx:=0, oTimerx, oProgress

DEFINE DIALOG oDLG FROM 01,01 TO 09,41 TITLE cTitle STYLE DS_MODALFRAME

oProgress = TProgress():New(02,01,oDlg,0,,,.F.,.F.,140,10)

nWidth=oDLG:nRight-oDLG:nLeft

oDlg:bStart = {|| Eval(bAction,oDlg),; 
                  oTimerx:End()     ,; 
                  oDlg:End()        ,; 
                  SysRefresh()       }


oDlg:bPainted = {|hdc| oDlg:Say(01,02,xPadr(cCaption,nWidth)), SysRefresh() }

ACTIVATE DIALOG oDlg CENTER ON INIT (xInic(oDlg),oTimerx:Activate(),SysRefresh())                         

RETURN                               
//---------------------------------------------------------------------------------

//---------------------------------------------------------------------------------
FUNCTION xInic(oDlg)
DEFINE TIMER oTimerx OF oDlg INTERVAL 1 ACTION (oProgress:SetPos(++nContx),;
                                                nContx:=IF(nContx>150,0,nContx),;
                                                SysRefresh())
RETURN
//---------------------------------------------------------------------------------


I need start another thread because a SQL query make a current thread busy
and the timer of the progress bar dont work...

In this case, I will call a timer from second thread...

Any sugestion ?

regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Thread on FWH
Posted: Thu Feb 19, 2009 12:15 AM
Yuri,

Please try it this way:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oDlg

   DEFINE DIALOG oDlg TITLE "Please wait..."

   ACTIVATE DIALOG oDlg NOWAIT CENTERED

   cSqlComand = "SELECT ID,Name,City,Country,Phone  FROM tbCustomers ORDER BY Name"
   USE 'tbCustomers' AS cSqlComand ALIAS 'TEMP' VIA 'MySQL'

   oDlg:End()

   SELECT TEMP
   GO TOP
   BROWSE()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Re: Thread on FWH
Posted: Thu Feb 19, 2009 02:49 PM

Hello Mr.Antonio,

In time I am already make this way (with a static message), but what I
wanted was a progress bar refreshed by action timer , but it is only possible
with a mult-thread support, what isn't yet avaliable

anyway, many thanks for your help and attention

regards

Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Thread on FWH
Posted: Thu Feb 19, 2009 05:03 PM

Why not using a timer?

EMG

Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Re: Thread on FWH
Posted: Thu Feb 19, 2009 05:44 PM

Hello Enrico,

I am trying to use a timer (see code in the top of the post), but when the SQL query is being
executed the main thread stays busy, and turn off the timer, only turn on when the SQL query
finish (because the same thread is used for SQL query and for the timer)

In this case would be necessary start a second thread (mult-thread), but it is not yet available in FHW (as far as I know)

regards

Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Thread on FWH
Posted: Thu Feb 19, 2009 06:21 PM

Unfortunately, you are right... :-(

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Thread on FWH
Posted: Thu Feb 19, 2009 06:52 PM

Yuri, Enrico,

What it is stopping us from using a TIMER is the USE command itself:

USE 'tbCustomers' AS cSqlComand ALIAS 'TEMP' VIA 'MySQL'

as it does not call to SysRefresh() (or an equivalent one) so the Windows messages are not processed in the meantime, thus the TIMER does not receive any event.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion