Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't get VFP to auto-shutdown each night
Message
From
18/12/2002 14:58:56
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00733898
Message ID:
00734214
Views:
89
Hi David,

Below suggestion worked. I replaced the call to .Destroy() with .Release(); I think I had it the right way originally but could not get the app to close with a QUIT so I think I tried the .Destroy(). I also found that CLEAR EVENTS worked from the timer method so I put it there right under the .Release() instead of augmenting default code in .Destroy() (and it would easily be found by someone else). Also, by putting it in the timer event, the only time CLEAR EVENTS is issued is during the "Auto shutdown" at night, not when the form is destroyed for any other reason (I could have gotten around this by creating a form property something like .ilFormReleaseByAutoShutdown and then only issuing CLEAR EVENTS in .Destroy() if this was set to .T. (default would be .F.). Anyhow, it works so thanks.

>Albert,
>
>You can't really call Destroy(). It is an event that happens when an object is destructing. Calling the Destroy() method does not cause the object to be destroyed, all it does is run whatever code you happen to have put into the method.
>
>I think you'd be better off in your Timer doing something like:
>
>
>
>IF VAL(LEFT(TIME(),2)) >= 23
>
>   * destroy the object and then try to quit
>   thisform.Release()
>ENDIF
>
>
>Where the form.Destroy() issues a CLEAR EVENTS which will let your server continue on past the READ EVENTS you executed to keep the exe running in the first place.
>
>This also kind of assumes that the program will never run between the hours of 11pm to midnight.
>
>>We have a VFP app running as a service on one of our servers. It opens up data files and chugs along all day. But at night, I want to have it shut itself down at 11 pm so we get a better backup of data.
>>
>>It is a visual process as it displays a form that shows errors, number of jobs processed etc. So on this form I have a timer object that both checks for new jobs (every 5 seconds) and then also checks the current time and if after 11 pm, it tries to shut the app down. Here is the code I use (in the timer event of the timer):
>>
>>IF VAL(LEFT(TIME(),2)) >= 23
>>
>> * destroy the object and then try to quit
>> ON ERROR
>> THISFORM.Destroy
>>
>> ON SHUTDOWN
>> QUIT
>>
>>ENDIF
>>
>>******** END OF CODE ***
>>
>>Result: it closes the form and therefore *most* dbf files are closed (the form is a private data session so they open files close when the form closes) but the app as a whole does not close ie. I am left with the main screen up and the menus. Also, checking backup log files, I have a few files left open that are opened when the app starts up ie. in the default datasession.
>>
>>I did something similar to this in the old days (FPD2.6) and it worked ie. Quit worked pretty well from anywhere!
>>
>>Is there anything else I need to kill before issuing Quit? Do I need to somehow kill the form from outside the form (on the screen?) so that there is no form open when Quit is issued?
>>
>>Albert
Previous
Reply
Map
View

Click here to load this message in the networking platform