Timers and loops

Re: Timers and loops

Postby Enrico Maria Giordano » Fri Feb 05, 2010 11:04 am

Thank you, but you still missed the point. Please re-read my previous messages.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8418
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Timers and loops

Postby Jack » Fri Feb 05, 2010 11:28 am

Here is what i do :

static osuivi,osays1,wvars2
function main()
local ii
wvars2:=0
suivi()
*
ii:=0
do while ! eof()
wvars2:=ii
oSays1:setText(wvars2)
oSays1:refresh()
i++

* a lot of action

SKIP
enddo
*
oSuivi:end()
*
return .T.


* ===
procedure suivi()
DEFINE DIALOG oSuivi TITLE "Progress info" FROM 3,3 TO 8,50
@ 1,1 say oSays1 prompt wVars2 UPDATE of oSuivi size 80,10
ACTIVATE DIALOG oSuivi NOWAIT CENTERED
RETURN
Jack
 
Posts: 282
Joined: Wed Jul 11, 2007 11:06 am

Re: Timers and loops

Postby Enrico Maria Giordano » Fri Feb 05, 2010 11:39 am

Thank you. Sorry, I already use a similar technique in specific loops but its application in all the existing loops would require too much work (I have 348 PRGs containing such loops or iterative command like REPLACE ... FOR, etc.).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8418
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Timers and loops

Postby Antonio Linares » Fri Feb 05, 2010 3:21 pm

Enrico,

You could show an AVI file in your MsgBox() function
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Timers and loops

Postby Enrico Maria Giordano » Fri Feb 05, 2010 3:59 pm

I think the AVI stops the animation too, if it uses a timer. Am I wrong?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8418
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Timers and loops

Postby James Bott » Fri Feb 05, 2010 4:11 pm

Enrico,

> Anyway, I don't really need to get the rest of the system responding fast during my waiting loops.

Maybe you don't care but your users probably do. Perhaps they want to do something else while waiting, like check their email or something. It is good and polite practice to put sysrefresh() in all loops that take more that a few seconds to complete.

I hate it when an application freezes my computer.

Ewe's idea is also a good one. For up to about 10-15 seconds I would use an hourglass cursor, for more time I would use a progress bar if possible, or some kind of animation if you do not have the data for a progress bar.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Timers and loops

Postby Enrico Maria Giordano » Fri Feb 05, 2010 5:00 pm

I agree. But I just can not afford the huge work necessary to change all of my loops. And some of them are not explicit loops as INDEX ON or REPLACE ALL.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8418
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Timers and loops

Postby Patrizio » Mon Feb 08, 2010 10:31 am

Enrico Maria Giordano wrote:No, other apps don't stop. Maybe I can use threads but I'm not familiar with them.

EMG


You can't use mt with FiveWin :(
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

Re: Timers and loops

Postby Antonio Linares » Mon Feb 08, 2010 9:03 pm

Patrizio,

Have you tried to use mt with FiveWin ? :-)

mt should work fine except for some GUI components (modal dialog boxes)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Timers and loops

Postby anserkk » Tue Feb 09, 2010 4:42 am

Dear Mr.Antonio,

mt should work fine except for some GUI components (modal dialog boxes)


Can we have a small sample demonstrating the usage of multi threading with Fivewin. Do xHarbour support this ?

Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Timers and loops

Postby Patrizio » Tue Feb 09, 2010 8:07 am

Antonio Linares wrote:Patrizio,

Have you tried to use mt with FiveWin ? :-)

mt should work fine except for some GUI components (modal dialog boxes)


Antonio, i just read your first post in this thread: viewtopic.php?f=3&t=10439&hilit=multithread

Once there is a good support for threads in Harbour/xHarbour, then we will be able to adapt FWH to multithreading.


But, i've tried a small sample and it works fine. So, can we use multi-thread with FWH? When we can use it with modal dialog boxes? Which GUI components don't work?

@Anserkk: this is compiled with FWH and xHarbour. Remark to check the "multi thread support" on xbuilder.

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
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

Re: Timers and loops

Postby anserkk » Tue Feb 09, 2010 9:41 am

Dear Mr.Patrizio,

Thanks for the sample. Which xHarbour lib is to be added. I am getting unresolved external

When I tried to use BuildX.Bat then the following xHarbour functions are missing
Code: Select all  Expand view
HB_MUTEXCREATE
STARTTHREAD
WAITFORTHREADS
MUTEXLOCK
GETTHREADID
GETSYSTEMTHREADID
MUTEXUNLOCK
 


When I tried to use BuildH.Bat then the following Harbour functions are missing.
Code: Select all  Expand view
STARTTHREAD
WAITFORTHREADS
GETTHREADID
GETSYSTEMTHREADID



Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Timers and loops

Postby Patrizio » Tue Feb 09, 2010 10:30 am

anserkk wrote:Dear Mr.Patrizio,

Thanks for the sample. Which xHarbour lib is to be added. I am getting unresolved external


You must use the lib with the sufix "MT" when they are present... i see on my linker log this: "OptGMT.lib" "xhbmt.lib" "dbfmt.lib" "nsxmt.lib" "ntxmt.lib" "cdxmt.lib" crtmt.lib
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

Re: Timers and loops

Postby anserkk » Tue Feb 09, 2010 12:44 pm

Hi,

xHarbour VmMt.Lib contains all the missing MultiThread related functions

Code: Select all  Expand view
HB_MUTEXCREATE
STARTTHREAD
WAITFORTHREADS
MUTEXLOCK
GETTHREADID
GETSYSTEMTHREADID
MUTEXUNLOCK


Unfortunately when I compile, I am still getting Unresolved Externals calls from VmMt.Lib to the following functions

__endthreadex
__beginthreadex


Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Timers and loops

Postby Patrizio » Tue Feb 09, 2010 4:28 pm

anserkk wrote:Hi,

xHarbour VmMt.Lib contains all the missing MultiThread related functions

Code: Select all  Expand view
HB_MUTEXCREATE
STARTTHREAD
WAITFORTHREADS
MUTEXLOCK
GETTHREADID
GETSYSTEMTHREADID
MUTEXUNLOCK


Unfortunately when I compile, I am still getting Unresolved Externals calls from VmMt.Lib to the following functions

__endthreadex
__beginthreadex


Regards
Anser


crtmt.lib
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 31 guests