Solved

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

Posted on 2003-10-26
3
193 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now