Hi!
Following is what I usually use.
First of all, instead of using Enabled property of time, use Interval property to disable timer firing for a duration of the process. For example:
m.lnInterval = this.Interval
this.Interval = 0
... do a code of timer event
this.Interval = m.lnInterval
Second, always check if SQLEXEC() really returned error by using
"if SqlExec(handle,"select ...","MyAlias")<0"
Third, you do not need to set up ColumnCount to zero and than back again. THis fire a LOT of internal VFP events and I afraid you can get even C0000005 crash just because too much of them (with grids it is a problem) - thsi is just a suggestion from some past posts about grids.
Finally, call Grid.Refresh method just after you prepared it and before enabling timer.
Also, just a suggestion: try change the value if _VFP.AutoYield and see what happens.
HTH.
>I have a form with grid and timer. It 24 hours/day displaing some data. Timer interval is between 10 and 60 seconds. This form running sometime 1 week without error and sometime it crashes after hours.
>Timer event call this code:
>
>thisform.timer.enabled=.f.
>thisform.grid.RecordSource=""
>thisform.grid.ColumnCount=0
>* select from Oracle backend
>if SqlExec(handle,"select ...","MyAlias")
> if reccount()=0
> * display no data
> else
> with thisform.grid
> .ColumnCount=5
> .RecordSource="MyAlias"
> endwith
> with thisform.grid.column1
> .ControlSource="MyAlias.field1"
> .DynamicBackColor="iif(MyAlias.field5=1,rgb(255,0,0),rgb(255,255,255))"
> endwith
> * other columns, only text controls
> endif
>else
> * display error connection to Oracle
>endif
>thisform.timer1.enabled=.t.
>*(I'm making all my grids this way with no problems.)
>
>Error is coming with "error 10" - syntax of DynamicBackColor is invalid. Why ?
>So I run this form in development environment and after some days I've got the error and under this I found popular error C000005.
>
>I found only one way - put ListBox instead of grid. But it's not solving problem.
>
>Does help removing and adding grid object or other trick ?
>
>Pavel
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.