PROGRAM (Not Responding)

Post Reply
dagiayunus
Posts: 69
Joined: Wed Nov 19, 2014 1:04 pm
Contact:

PROGRAM (Not Responding)

Post by dagiayunus »

Dear Sir,

My app not responding sometimes. I am using timer & xbrowse in app.

Code: Select all

      DEFINE WINDOW oWnd Title "Messaging system"
 

      
      DEFINE MSGBAR PROMPT "Msg System" ;
      OF oWnd 2007 KEYBOARD DATE TIME           
      
       
         @ 0, 0 XBROWSE oBrw OF oWnd LINES AUTOSORT ;
                 COLUMNS "MSGFROM","MSG","REPLY","MSGDT" ALIAS "TGMSGS" NOBORDER

      OBrw:nRowHeight:=25
    
      oBRW:REPLY:nEditType :=EDIT_GET      
      oBrw:REPLY:bEditWhen  := { || oTimer:Deactivate() }
      oBrw:REPLY:bEditValid := { |o| (oTimer:Activate(),Dmsg(TGMSGS->CHATID,o:VarGet()),.t.) }
     
      
       
      
      oBrw:CreateFromCode()
      
     // oBrw:bLDblClick = { || oBrw:EditSource(,, .T.) }
      
      oWnd:oClient = oBrw     
                
             
      
   Define Timer oTimer Interval 4000 Action UpdateDbf() OF oWnd
   Activate Timer oTimer

ACTIVATE WINDOW oWnd MAXIMIZED      

oTimer:End()    

RETURN NIL
   
function UpdateDbf()
//local nRec:=TGMsgs->(Recno())
oTimer:Deactivate()
ReadMessages()  // Read mesages using http post from telegram and appned to dbf
sysrefresh()
AutoReplyMsg()  // reply msgs using http post
sysrefresh()

oTimer:Activate()
oBrw:setfocus()
sysrefresh()   
return nil  
Regards
Yunus
Dagia Yunus.
Rajkot, India

FWH 17.04
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: PROGRAM (Not Responding)

Post by Antonio Linares »

Yunus,

Try to use a static var to avoid recursion:

Code: Select all

function UpdateDbf()

   static lWorking := .F.

   if ! lWorking
      lWorking = .T.
      oTimer:Deactivate()
      ReadMessages()  // Read mesages using http post from telegram and appned to dbf
      sysrefresh()
      AutoReplyMsg()  // reply msgs using http post
      sysrefresh()

      oTimer:Activate()
      oBrw:setfocus()
      sysrefresh()   
      lWorking = .F.
   endif

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
dagiayunus
Posts: 69
Joined: Wed Nov 19, 2014 1:04 pm
Contact:

Re: PROGRAM (Not Responding)

Post by dagiayunus »

Sir,

Program still not responding sometimes. Is there any other method? I am using harbour. Can I run any function in background to fetch the data and update the dbf? How ?

Thanks & Regards

YUnus.
Dagia Yunus.
Rajkot, India

FWH 17.04
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: PROGRAM (Not Responding)

Post by Antonio Linares »

Yunus,

Please post a self contained example to reproduce it here, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
dagiayunus
Posts: 69
Joined: Wed Nov 19, 2014 1:04 pm
Contact:

Re: PROGRAM (Not Responding)

Post by dagiayunus »

Code: Select all

#INCLUDE "FIVEWIN.CH"
#include "xbrowse.ch"
#include "common.ch"

static lWorking := .F.
static odoc,ohttp,cTOKENshop,cTOKENadmin


function Main()
   
  odoc  := CreateObject( "MSXML2.DOMDocument" )
   ohttp := CreateObject( "MSXML2.XMLHTTP" )
   cTOKENShop:="TOKEN VALUE 1"
   cTOKENAdmin:="TOKEN VALUE 2"
   SET DATE BRITISH
   SET CENTURY ON
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR(DATE())-50
   SET 3DLOOK ON
   REQUEST DBFCDX
   SETHANDLECOUNT( 250 )
   XbrNumFormat( 'A', .t. )
   SetKinetic( .f. )
   SetGetColorFocus()
   SetBalloon( .t. )


    DEFINE WINDOW oWnd Title "Test Messaging" /
      @ 0, 0 XBROWSE oBrw OF oWnd LINES AUTOSORT ;
                 COLUMNS "MSGDT","MSGFROM","MSG","REPLY","REPLIED" ALIAS "TGMSGS" NOBORDER ;
                 PICTURE ,,,,"Y"

       //OBrw:nRowHeight:=25
       oBrw:nStretchCol   := STRETCHCOL_WIDEST
       oBrw:acols[1]:nWidth :=120
       oBrw:acols[2]:nWidth :=200
       oBrw:acols[3]:nWidth :=200
       oBrw:acols[4]:nWidth :=300
       oBrw:MSGDT:nDataStrAlign := AL_CENTER
       oBrw:MSGFROM:nDataStrAlign := AL_CENTER
       oBrw:REPLIED:nDataStrAlign := AL_CENTER
    
      oBRW:REPLY:nEditType :=EDIT_GET      
      //oBrw:REPLY:bEditWhen  := { || oTimer:Deactivate() }
      //oBrw:REPLY:bEditValid := { |o| (oTimer:Activate(),Dmsg(TGMSGS->CHATID,o:VarGet()),.t.) }
      
      oBRW:REPLIED:nEditType :=EDIT_GET      
      //oBrw:REPLIED:bEditWhen  := { || oTimer:Deactivate() }
      //oBrw:REPLIED:bEditValid := { |o| (oTimer:Activate(),.t.) }
     
      
       
      
      oBrw:CreateFromCode()
      
      oWnd:oClient = oBrw
     
    
                      
             
      
  Define Timer oTimer Interval 1500 Action UpdateSendReceive() OF oWnd
  Activate Timer oTimer

ACTIVATE WINDOW oWnd MAXIMIZED        
   
oHttp:=Nil
Odoc:=Nil
CLOSE ALL

RETURN NIL


  
function UpdateSendReceive()
if ! lWorking  //as advice by your kindself using static var 
   lWorking = .T.
   //oTimer:Deactivate()
   sysrefresh()
   ReadMessage()
  sysrefresh()   
  ReplyMsg()
   obrw:Refresh()
   lWorking = .F.
   oTimer:Activate()
   sysrefresh()   
endif      
return nil
Dagia Yunus.
Rajkot, India

FWH 17.04
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: PROGRAM (Not Responding)

Post by Antonio Linares »

Yunus,

Why do you deactivate the timer ?

//oTimer:Deactivate()
regards, saludos

Antonio Linares
www.fivetechsoft.com
dagiayunus
Posts: 69
Joined: Wed Nov 19, 2014 1:04 pm
Contact:

Re: PROGRAM (Not Responding) (solved)

Post by dagiayunus »

to debug the program i deactivated it. but it was causing the problem.

it solved. thanks sir.
Dagia Yunus.
Rajkot, India

FWH 17.04
Post Reply