![]() |
Re: Fragen zum TThread, Programm absturzsicher?
Ok, ich habe es mal getestet (in D7)
|
Re: Fragen zum TThread, Programm absturzsicher?
@ sirius,
also erstmal danke für deine Mühen, aber kannst du da nochmal etwas genauer drauf eingehen? Ich hab das nicht wirklich verstanden, wie ich das Hauptthread absturzsicher mache. Könntest das eventuell nochmal etwas genauer erklären? also bei meinem Rad Studio 2006 ist bisher immer beide Threads durchgebrannt bei einer Exception. Hab noch keinen Weg gefunden, wie ich das verhindern kann. Dies scheint dir ja gelungen zu sein. Auch Danke an euch andere. BAMatze |
Re: Fragen zum TThread, Programm absturzsicher?
nunja, am einfachsten scheint es zu sein, wenn du alle Hauptprozeduren deiner Thread und des Hauptthreads in Try Except verpackst.
|
Re: Fragen zum TThread, Programm absturzsicher?
Zitat:
|
Re: Fragen zum TThread, Programm absturzsicher?
siehe
![]() k.A. ob's funktioniert
Delphi-Quellcode:
hier hab ich mal alles verpackt und versucht die Finalisierung von Application nachzubauen:
Program MyProgram;
Uses SysUtils, Forms, Unit1; Var doRestart: Boolean; Begin Application.Initialize; Application.CreateForm(TForm1, Form1); Repeat doRestart := False; Try Application.Run; Except doRestart := True; End; Until doRestart and not Application.Terminated; End.
Delphi-Quellcode:
aber eigentlich die die Nachrichtenbearbeitung des Hauptthreads (im .Run) auch per Try-Except abgesichert.
Uses SysUtils, Classes, Forms, Unit1;
Function FindGlobalComponent(Const Name: String): TComponent; Var i: Integer; Begin For i := 0 to Screen.FormCount - 1 do Begin Result := Screen.Forms[i]; If not (csInline in Result.ComponentState) and (CompareText(Name, Result.Name) = 0) Then Exit; End; For i := 0 to Screen.DataModuleCount - 1 do Begin Result := Screen.DataModules[i]; If CompareText(Name, Result.Name) = 0 Then Exit; End; Result := nil; End; Var doRestart: Boolean; Begin Repeat doRestart := False; Try Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; Except doRestart := True; Try If (Application <> nil) and (Application.Handle <> 0) Then Begin Application.Minimize; Application.ShowHint := False; Application.Destroying; Application.DestroyComponents; End; // If HintDoneEvent <> 0 Then CloseHandle(HintDoneEvent); UnregisterFindGlobalComponentProc(FindGlobalComponent); Except End; End; Until doRestart and not Application.Terminated; End. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:45 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz