AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Windows tötet Delphi-Anwendung noch vor Unit-Finalisierung

Windows tötet Delphi-Anwendung noch vor Unit-Finalisierung

Ein Thema von Der schöne Günther · begonnen am 23. Dez 2015 · letzter Beitrag vom 24. Dez 2015
Antwort Antwort
Seite 2 von 2     12
Der schöne Günther
Online

Registriert seit: 6. Mär 2013
6.091 Beiträge
 
Delphi 10 Seattle Enterprise
 
#11

AW: Windows tötet Delphi-Anwendung noch vor Unit-Finalisierung

  Alt 24. Dez 2015, 11:23
Hört sich an wie eine Darmerkrankung

// 1. Update

Und mein Verdacht erhärtet sich! Wenn ich in meinem WM_ENDSESSION das Hauptformular abbaue, wird die Anwendung von Windows gekillt. Er scheint wirklich zu meinen "So, sind ja alle Fenster weg, können wir hier ja zumachen". Ein einfaches Form1.Destroy() reicht schon, alles danach wird nicht mehr ausgeführt!

Was ist nun wenn wir das Hauptformular nicht zerstören? Wie Raymon Chen schon sagte:
Zitat:
Besides, why spend your time closing windows when the session is about to go away anyway? Ooh, let me clean up this and destroy that, I know you asked to shut down, but this’ll just take a few seconds. It’s like taking the time to steam-clean the rugs before you demolish the building. Wasted effort.
Mein QuickFix sieht so (schlimm) aus:

Delphi-Quellcode:
destructor TForm1.Destroy;
begin
   if (Application.MainForm = self) then
      // do nothing
   else
      inherited;
end;
Was geschieht dann? Alles was ich möchte. Die Anwendung wird ordentlich beendet, die Dinge im finalization-Abschnitt der Unit werden ausgeführt und der Klassendestruktor auch. War es doch so einfach?


// 2. Update

Und die Bestätigung ist wohl auch da. Die Anwendung geht reproduzierbar tot wenn ich beim Herunterfahren nur sage WinApi.Windows.DestroyWindow(Form1.Handle); Tja, die Doku zu WM_ENDSESSION sagte
Zitat:
The application need not call the DestroyWindow or PostQuitMessage function when the session is ending.
"Need not call" ist nach meinem Englisch "muss nicht".

Hätte ich Idiot ausnahmsweise mal die Kommentare auf der MSDN-Seite weiter unten geleasen. Ein werter Herr bestätigt exakt meine Erlebnisse:
Zitat:
The documentation says you need not call DestroyWindow() inside your WM_ENDSESSION handler, but in my experience you *must* not call DestroyWindow(). Otherwise, the system might nuke your process before DestroyWindow() returns.
Das ist es also. Was wäre nun ein ordentliches Ende für diese Odyssee? Ich tue mich schwer auf eine konkrete Stelle im VCL-Code zu zeigen und zu sagen "Das sollte anders gemacht werden".

Geändert von Der schöne Günther (24. Dez 2015 um 12:58 Uhr)
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:03 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz