Network update problem with timer

Network update problem with timer

Postby Marc Vanzegbroeck » Thu Jan 29, 2009 10:49 pm

Hi,

I have a strange network problem. I use in my program a nummeric field with contain a number.
Each time something is update in the program I increase this value.
In my program I have a timer that check the value. If it has been change, something must be done.

The problem is now that only the program that increase the value see the value-change. The other PC still show the old value.

I have make a sample-code so you can test this. I show every 10seconds the value + time() in the title of the dialog.
You can see the timer is executed, because the time change. The only thing that is not changing is the value...

To test this, hou have to run it on a network on 2 PC's. If you press 'Add' the value is changed, but only on that PC, not on the other.
What can be the problem? I do a commit after increasing the value.

Code: Select all  Expand view  RUN
#INCLUDE "FiveWin.ch"
static sDlg
FUNCTION test()
   local  oWnd
   local vstruct:={}
   IF !file('refresh.dbf')
      aadd(vstruct,{'NR','N',10,0})
      dbcreate('refresh',vstruct)
   ENDIF
   use refresh new shared
   IF reccount()= 0
      appe blank
      unlock
   ENDIF

   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 TITLE "Test"

   ACTIVATE WINDOW oWnd MAXIMIZED on init test_()
RETURN nil

FUNCTION test_()
   local  oBtn ,oTim
   Define Timer oTim Interval 10000 Action chkrefresh()
   activate timer oTim

   DEFINE DIALOG sDlg FROM 5, 5 TO 15, 40 TITLE "Test"

   @ 3,  4 BUTTON "&Add" OF sDlg SIZE 40, 12 ACTION telop()

   @ 3, 12 BUTTON "&Exit" OF sDlg SIZE 40, 12  ACTION sDlg:End()

   ACTIVATE DIALOG sDlg
   release timer oTim
RETURN nil

FUNCTION telop()
   sele refresh
   IF rlock()
      repl nr with nr+1
      unlock
   ENDIF
   dbcommit()
RETURN nil

FUNCTION chkrefresh()
   sDlg:Settext(str(refresh->nr)+' '+time())
RETURN nil


Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network update problem with timer

Postby Marc Vanzegbroeck » Fri Jan 30, 2009 11:00 am

Any suggestions?

BTW You can also try it on one PC with VMWare :lol:

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network update problem with timer

Postby Enrico Maria Giordano » Fri Jan 30, 2009 12:08 pm

A workaroud:

Code: Select all  Expand view  RUN
FUNCTION chkrefresh()
   use refresh shared
   sDlg:Settext(str(refresh->nr)+' '+time())
RETURN nil


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

Re: Network update problem with timer

Postby Otto » Fri Jan 30, 2009 12:14 pm

Hello Marc,

First I thought maybe „refresh“ is a non allowed word.
I changed all to re_fresh. But this didn’t help.

But if you position before reading the data to record 1 for me it is working perfectly.



Best regards,
Otto



FUNCTION chkre_fresh()
local nCounter
select re_fresh
goto 1
nCounter:= re_fresh->nr

sDlg:Settext(str(nCounter)+' '+time())
RETURN nil
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Network update problem with timer

Postby Marc Vanzegbroeck » Fri Jan 30, 2009 12:47 pm

Thanks Otto, I will try it this evening. I'm at the moment with a client...

Enrico, I prefer using the 'goto 1' suggestion of Otto, then opening the database again.

It's very strange that the program doen't see the change, only when he's changing it himself.

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network update problem with timer

Postby Enrico Maria Giordano » Fri Jan 30, 2009 1:40 pm

Marc Vanzegbroeck wrote:Enrico, I prefer using the 'goto 1' suggestion of Otto, then opening the database again.


I agree, it's definitely a better workaround than mine.

Marc Vanzegbroeck wrote:It's very strange that the program doen't see the change, only when he's changing it himself.


I'm going to report this strange behavior to the Harbour and xHarbour developers lists.

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

Re: Network update problem with timer

Postby Enrico Maria Giordano » Fri Jan 30, 2009 2:23 pm

Done. In the meanwhile, you can use an even better workaround: Skip 0.

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

Re: Network update problem with timer

Postby Enrico Maria Giordano » Fri Jan 30, 2009 2:34 pm

This is the answer of a Harbour developer:

> Is it expected?

Hi,

yes, of cause. The whole record buffer is written to file after record
cursor is "touched". This helps to avoid multiple disk access on:
FIELD1 := value1
FIELD2 := value2
...
FIELDn := valuen

Use DBCOMMIT() (or move record pointer DBSKIP(), DBGOTO(), etc.) to
force write of record buffer.


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

Re: Network update problem with timer

Postby Marc Vanzegbroeck » Fri Jan 30, 2009 3:55 pm

Enrico,

As you can see I use dbcommit() in function telop() after changing the value.
Do they mean to use it also before reading?

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Network update problem with timer

Postby Otto » Fri Jan 30, 2009 4:40 pm

Hello Marc, hello Enrico,

I have the same result as Marc. If I watch with WDBU I see the changes.
I think the problem is reading without explicit positioning the record.

Regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Network update problem with timer

Postby Enrico Maria Giordano » Fri Jan 30, 2009 5:18 pm

Marc Vanzegbroeck wrote:Enrico,

As you can see I use dbcommit() in function telop() after changing the value.
Do they mean to use it also before reading?

Regards,
Marc


Yes. But Skip 0 is enough.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 16 guests