Solved

Shutting down a network application...

Posted on 2000-03-17
9
156 Views
Last Modified: 2010-04-04
This question is worth 0 points because I have no points to give right now.  If you are feeling charitable, by all means continue reading.  I leave the decision to you.

I have an application I wrote that resides on a network drive.  One big problem is whenever I want to update the .exe I have to wait until everyone has exited out of the program, because I can't replace the .exe when it is in use.

What I want to do is figure out a graceful way to exit the application, giving those who are actively using the program enough time to finish what they are doing and exit before the program dies.

I want to create the ability to "down" the program by some means.  My thought right now is to set up a TTimer event that checks for the existence of a file every so often.  Let's say the file is called KILLME.TXT.  The code would look something like this:

procedure TFormMain.Timer1Timer(Sender: TObject);
begin
  if FileExists('KILLME.TXT')then
     Application.Terminate;
end;

Now, this method is not smart because other dialogs may be open at the time or the user may be in the middle of something.

Any ideas?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2630443
Use some kinda spawner. An app that starts the main app. The spawner app checks a file which version of the main app should be run.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 2630462
Okay, this works for people trying to run the application, but what about if it is already running before I change the "valid" version number?
0
 
LVL 17

Accepted Solution

by:
inthe earned 20 total points
ID: 2630479
maybe
if FileExists('KILLME.TXT')then
showmessage('this app is shutting down for upgrade in 5 mins,please save and close what you are doing and go get a coffee');
start a new timer for 5 mins
timer1.enabled := false;
timer2.enabled:= true;
then on
timer2.ontimer event afre the 5 mins
     Application.Terminate;
end;

i would do somethign like this in conjunction with what epsylon said about having a file version to check on start also..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:Epsylon
ID: 2630488
0
 
LVL 1

Expert Comment

by:nrico
ID: 2639906
I think inthe's answer is indeed the best solution.
However, the program could save all data to disk itself (Let's say to \WINDOWS\TEMP\UPDATESAVE), set a registry setting that it's being updated and close down. It then spawns a program that keeps checking for the file UPDATECOMPLETE.TXT, and launches the program once it finds it there.

When the program is booted, it checks for the registry setting that it has been updated, removes it and loads all data back from \WINDOWS\TEMP\UPDATESAVE.

Of course, these things are all accompanied by nice messages telling the user what's happening -- I know I wouldn't like it if my program terminated on me without me knowing what happened!
0
 
LVL 1

Expert Comment

by:nrico
ID: 2639920
Ummm... You understand that the application launches a waiting program *BEFORE* it closes down... ? :-)
Sorry...
0
 
LVL 1

Expert Comment

by:nrico
ID: 2639924
Hey, you should have 15 points again by now!!
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 2640624
Adjusted points from 0 to 20
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 2640625
Increasing points to 20 now.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month7 days, 9 hours left to enroll

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question