Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 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