•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 456,562 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,507 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 2243 | Replies: 9 | Solved
![]() |
Worst/Quickest/Unelegant method? (assuming you don't just make a console app)
1. Drop a TTimer on the form
2. In the OnTimer event:
Timer1.enabled=false;
SendEmail(); <-- whatever it is you do
self.close
Better/More elegant: If your email has an event "OnSent" or something, you could call self.close there.
Best: console application. Just have it open, create the email components, fire and close.
1. Drop a TTimer on the form
2. In the OnTimer event:
Timer1.enabled=false;
SendEmail(); <-- whatever it is you do
self.close
Better/More elegant: If your email has an event "OnSent" or something, you could call self.close there.
Best: console application. Just have it open, create the email components, fire and close.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
•
•
Join Date: Oct 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
The best way to terminate an application is to call
application.terminate
This prevents a lot of problems and can be called anywhere.
Avoid using tTimer as much as possible because it is a "heavy" object --chewing up resources and time.
Hope this helps.
Hello and thanks for your reply.
I tried the Application.Terminate (think it's still in there) but it didn't terminate the application.
As it is the Ontimer seems to be the only solution that works. Resources are not a problem since the app. is very small and fast executing.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
•
•
Join Date: Oct 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
I'd be interested to know why application.terminate didn't stop your program. Have you got unusual hooks in there somewhere? Did your code actually call it?
The problem with the timer is that there is a system limit on the number of timers available. It doesn't matter how big your application is.
I had the Application.Terminate in the wrong place it seems. (After Application.Run).
Moving it to the end of the OnCreate (where all the work is done) solved the problem.
Thanks for you'r suggestion.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
•
•
Join Date: Sep 2007
Posts: 69
Reputation:
Rep Power: 2
Solved Threads: 7
Guess you are not looking for an alternate solution any more but in case you are - the best thing to do is to create a console app. You should only need to code one unit and from there do the email sending in the initialization section, do any residual housekeeping in the finalization section and you are done.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
If you are still going to mess with it...
Forget the console app, initialization and finalization, and all those other loops.
Just don't bother creating any forms. Don't call application.run.
Just do your stuff in the application .dpr file's begin..end block, and let the program terminate naturally when it hits the end.
Good luck.
Forget the console app, initialization and finalization, and all those other loops.
Just don't bother creating any forms. Don't call application.run.
Just do your stuff in the application .dpr file's begin..end block, and let the program terminate naturally when it hits the end.
Delphi Syntax (Toggle Plain Text)
program fooey; uses Classes; var foo: tFileStream; s: string = 'Hello, world!'; begin foo := tFileStream.create( 'fooey.txt', fmCreate or fmOpenWrite ); foo.write( pChar( s )^, length( s ) ) end.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Updating an Access database with a secondary form (VB.NET)
- MDI Child Form Placement (C#)
- Quick VB2005 help....how do I get this basic app started? (VB.NET)
- please take some time to help me.. thank you very much! (C#)
- Data Update Wall Smack (C#)
- Manipulating A Database (C#)
- VB6 submit button sends information to BBChat (Visual Basic 4 / 5 / 6)
- Code for Exiting a C# Application (C#)
- Data App With Multiple Windows (Visual Basic 4 / 5 / 6)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: cause of error
- Next Thread: Array problem in Pascal



Glad you caught that.
Linear Mode