I have written a small application that sends an Email.
I would like it to terminate itself without any user action.
I end the OnCreate procedure with Self.Close, but the application keeps running.
What am i missing?
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.
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. :)
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.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...