Delphi wait program exit




















D wait and wait and wait and wait 3. ShellExecute Wait 5. Wait on ShellExecute 6. Wait after ShellExecute 7. Waiting for ShellExecute 8.

Waiting for ShellExecuted apps to terminate 9. Wait for ShellExecute command. Davinci Jeremi Delphi Developer. How do I wait for the application I execute using ShellExecute to finish before I continue processing anything else? Thanks Davinci. Terminate but it will process both OnCloseQuery and OnClose events of the main form if they were assigned. You can even prevent the application from closing by setting CanClose variable of OnCloseQuery event to false.

But calling Application. Terminate won't process those events. To prevent additional code in the current procedure from executing, use Exit; after Application. Terminate; instead of Halt; — crefird. Add a comment.

Active Oldest Votes. Terminate Ends application execution. Halt Initiates the abnormal termination of a program. Halt performs an abnormal termination of a program and returns to the operating system. Improve this answer. Remy Lebeau Remy Lebeau k 29 29 gold badges silver badges bronze badges. In this specific case, my goal is that to stop application without executing any other code line I just want to free everything and terminate the application.

As Application. Terminate is not immediate, should I use Halt or are there any possible trouble in using this? Halt does not free very much, but it does try to do some internal system cleanup. If your goal is to just bail out of the process immediately, you can use Halt , but if that is still too much code to execute, then you will have to resort to the Win32 API TerminateProcess function.

Thanks for clarification, I suppose Halt is enough for my requirements. I would like to terminate a Delphi application without executing any other code. David Heffernan David Heffernan k 40 40 gold badges silver badges bronze badges. ExitProcess will execute code. Such as DllMain. One should use TerminateProcess. Alex TerminateProcess is indeed even more brutal. TerminateProcess was once necessary evil for me. A third party library we needed was causing an exception at exit. If you do not know the state of all threads in your process, it is better to call TerminateProcess than ExitProcess — Ian Boyd.

Just to leave a point on a extra problem if code must be on main form OnCreate. To be able to see it, add another form and put on its creation a long loop. Sample code: procedure TMyMainForm.

Only way to not show [3] is to call Halt. Anonymous Anonymous 39 1 1 bronze badge. I mean, when on main form creating You call Application. Terminate, it almost do nothing, because main form creating are processed before Application. Run call from main application source in project file ".

Terminate are breaks main loop, but it still not started! That's fine in a background thread as it won't block the UI. When that wait completes, send a message to the UI thread.

The simple pattern for task creation and waiting until the work is done is shown by this pseudo code. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Delphi: Wait for threads to finish Ask Question. Asked 6 years, 2 months ago. Active 6 years, 2 months ago. Viewed 6k times. Improve this question. Amos Amos 1, 2 2 gold badges 23 23 silver badges 41 41 bronze badges.

AsyncCalls is no longer supported. As an alternative you might be interested in OmniThreadLibrary. It comes with a lot more documentation and examples for different use cases. I understand that waiting for all threads to finish in the background is supported? After making ASyncCalls work for me except for the small problem , I prefer not to adapt this one just to encounter the same problem. Do the WaitAll inside a thread and when ready, post a message to the main thread. Perhaps using TAsyncCalls.

I'll try this idea but it's funny that I need to use my own thread in order to handle the sophisticated thread pool mechanism : — Amos. Amos, it is not funny at all. The threading paradigm means that you have to make your program event driven.



0コメント

  • 1000 / 1000