PROGRAM (Not Responding)

PROGRAM (Not Responding)

Postby dagiayunus » Wed Oct 26, 2016 2:33 pm

Dear Sir,

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

Code: Select all  Expand view
     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
Regards
Yunus

FWH 21.02
dagiayunus
 
Posts: 85
Joined: Wed Nov 19, 2014 1:04 pm

Re: PROGRAM (Not Responding)

Postby Antonio Linares » Wed Oct 26, 2016 8:26 pm

Yunus,

Try to use a static var to avoid recursion:
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: PROGRAM (Not Responding)

Postby dagiayunus » Tue Nov 08, 2016 11:21 am

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.
Regards
Yunus

FWH 21.02
dagiayunus
 
Posts: 85
Joined: Wed Nov 19, 2014 1:04 pm

Re: PROGRAM (Not Responding)

Postby Antonio Linares » Tue Nov 08, 2016 11:29 am

Yunus,

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

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

Re: PROGRAM (Not Responding)

Postby dagiayunus » Tue Nov 08, 2016 11:36 am

Code: Select all  Expand view

#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
Regards
Yunus

FWH 21.02
dagiayunus
 
Posts: 85
Joined: Wed Nov 19, 2014 1:04 pm

Re: PROGRAM (Not Responding)

Postby Antonio Linares » Tue Nov 08, 2016 11:47 am

Yunus,

Why do you deactivate the timer ?

//oTimer:Deactivate()
regards, saludos

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

Re: PROGRAM (Not Responding) (solved)

Postby dagiayunus » Tue Nov 08, 2016 12:23 pm

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

it solved. thanks sir.
Regards
Yunus

FWH 21.02
dagiayunus
 
Posts: 85
Joined: Wed Nov 19, 2014 1:04 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 101 guests