Yunus,
Why do you deactivate the timer ?
//oTimer:Deactivate()
Yunus,
Why do you deactivate the timer ?
//oTimer:Deactivate()
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 nilfunction 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 nilSir,
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.
Yunus,
Please post a self contained example to reproduce it here, thanks
#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:bEditWhen := { || oTimer:Deactivate() }
//oBrw:bEditValid := { |o| (oTimer:Activate(),Dmsg(TGMSGS->CHATID,o:VarGet()),.t.) }
oBRW:REPLIED:nEditType :=EDIT_GET
//oBrw:bEditWhen := { || oTimer:Deactivate() }
//oBrw: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 nilto debug the program i deactivated it. but it was causing the problem.
it solved. thanks sir.