Solved

How to encase an external function from a dcu-file?

Posted on 2003-10-26
3
203 Views
Last Modified: 2010-04-05
Hello !
I`m working with d5. In my app i'm using a function from an external dcu-file. I don't have the source of this file. Sometimes this function runs (inside) in an endless loop and my app`s loosing the control...
Are there any possibilities to encase this function to get the exception from inside it? Constructs like "try...function-call...finally..." don't help - Sometimes it stops IN the function :-((
Are there any other solutions?
Best regards,
Ingo

BTW: 165 points are all i have ;-)
0
Comment
Question by:Ogni
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 165 total points
ID: 9625673
Hi,

If that function raises an exception then use:

try
  function call
except
  // do something here - error ocured
end;

If it sometimes runs an endless loop then perhaps running the function in a thread could be a solution (your program won't stop at least).

type
  TRunThread = class(TThread)
  public
    procedure Execute; override;
  end;

procedure TRunThread.Execute;
begin
  try
    function call;
  except
    // do something here - error ocured
  end;
end;

// usage
...
with TRunThread.Create(true) do begin         // create the thread but don't start it now...
    FreeOnTerminate := true; // set it to free itself at end
    Resume; // run it
end;
...

Regards, Geo
0
 

Author Comment

by:Ogni
ID: 9626019
Hi Geo !
Thanks a lot !!!
Best regards,
Ingo
0
 
LVL 17

Expert Comment

by:geobul
ID: 9626688
You are welcome :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question