Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Service program: UI form or not?
Message
 
 
To
10/05/2021 10:44:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680248
Message ID:
01680284
Views:
19
>>>>>>>Hello,
>>>>>>>
>>>>>>>I am working on creating a program which will be used as a service.
>>>>>>>
>>>>>>>In a nutshell, the program will consist of one form with a timer on it. The timer will run 24/7 and call a procedure every # minutes. The procedure will connect to SQL Server and based on some table/rows values will send email(s).
>>>>>>>
>>>>>>>Mainly the form will have a textbox which will show the end user the timer interval. My goad is to run the form minimized so that it won't be seen on the server. And the user will be able to change the timer interval by changing the text box value.
>>>>>>>
>>>>>>>A question:
>>>>>>>
>>>>>>>Can a program used as a service have a Form? Would the use have to stop the service to bring up the form to make a change?
>>>>>>>
>>>>>>>TIA
>>>>>>
>>>>>>I would not do a service as easy as it seems to be with whatever third party tool you might use.
>>>>>>
>>>>>>I would write a bullet proof with serious error logging FoxPro EXE that has no UI and doesn't use a Timer and have it run as a Windows scheduled task every x minutes.
>>>>>>
>>>>>>The Windows Scheduler logs the start of the task and is easier, IMO, to maintain and configure. I've used Windows Scheduler a lot and it works fine. You just have to write a very smart program that cannot fail without writing out an error log.
>>>>>>
>>>>>>Whether a Service can run a VFP EXE with a Form is something that I doubt can happen, but I don't know for sure.
>>>>>>
>>>>>>And in the past I've had trouble with FoxPro Timers where they don't fire.
>>>>>
>>>>>Thank you for your message
>>>>>
>>>>>Isn't the Windows Scheduler need someone to be logged in the VM/server for it to run?
>>>>
>>>>Whether you do a Service or a Windows Scheduler you're going to need to login some user in. And that user needs to have the rights to the folders your app needs. You might create a special login for this purpose as opposed to using your own login.
>>>
>>>Jeff, Dmitry,
>>>
>>>1) This is not correct. Services do not require any user to be logged in. They run under the System account. Rights to folders etc. can be set up as normal if needed.
>>>
>>>2) Normally service type apps should not have user interaction i.e. forms. Obviously anything in the app which stops to ask a user for input will stop until input provided. If the app is then run as a service then obviously there is no visual interaction and so the app stops and can never be answered. However, any app which has screen output only for status updates, as an example, can run as a service using ServiceMill. This is very useful because one can write and test and debug an app using visual output but then run it as a service using ServiceMill without any code changes - when the app runs as a service all screen output is suppressed. Just don’t create forms which wait for input which a user will not see when it is run as a service.
>>>
>>>We have had VFP apps running as services using ServiceMill for years and years. Works great. Just make sure to log errors and issues to a log file so you can see if there is a problem.
>>
>>First, thank you, Jos.
>>
>>Does your app, which is used as a service, uses a VFP timer? If yes, have you found any problems with it when using in a service application?
>
>No, no problem at all. If it runs properly as a normal VFP app it will run properly under ServiceMill. ServiceMill just creates a wrapper around your app to handle the service-under-Windows stuff. Otherwise your app runs just as your app would without ServiceMill. Just dont stop your app to ask the user for inout because there is no screen output when run as a service so the user never sees the prompt/request for input :) You can create screens/forms and have output but none of it is shown - it is all simply suppressed by ServiceMill.

Thank you very much. Of course, the application will run without asking any input (this is the purpose to make it run 24/7 and email when the data calls for it). The only input will be the timer interval. And it will be stored in an XML file and read on the start of the service/app. In theory I can create this app without a form. But the timer has to "live" somewhere and to me a form is just as good place for it as any :) And I understand that once the application starts (maybe after server reboots) it runs unattended. Simply connects to the SQL Server every # minutes and - based on some logic - emails or does nothing.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform