AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Fragen zum TThread, Programm absturzsicher?
Thema durchsuchen
Ansicht
Themen-Optionen

Fragen zum TThread, Programm absturzsicher?

Ein Thema von BAMatze · begonnen am 6. Feb 2009 · letzter Beitrag vom 8. Feb 2009
 
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.326 Beiträge
 
Delphi 12 Athens
 
#25

Re: Fragen zum TThread, Programm absturzsicher?

  Alt 8. Feb 2009, 22:00
siehe Beitrag #20, da bemerkt man, daß Delphi bei TThread die Thread-Prozedur (.Execute) schon mit einem Try-Except-Block absichert (zumindestens in "neueren" Delphiversionen)

k.A. ob's funktioniert
Delphi-Quellcode:
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.
hier hab ich mal alles verpackt und versucht die Finalisierung von Application nachzubauen:
Delphi-Quellcode:
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.
aber eigentlich die die Nachrichtenbearbeitung des Hauptthreads (im .Run) auch per Try-Except abgesichert.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
 


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 06:48 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 by Thomas Breitkreuz