Function hook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there:
I wanna know does it exist in C# that when I call a method, say
myObj.Dummy(), I could caculate the call time of the Dummy() method, if the
time exceed the given value , I could cancel the Dummy() . does C# have the
mechanism?
 
Peter Bromberg said:
You can make any method call "timeout-able" with the use of delegates.
Here
is an article that illustrates one method to do this:

http://www.eggheadcafe.com/tutorial...e5-5b61f049019f/basics-make-any-method-c.aspx

But note that 5000 should be 5 * secondsToWait, and that this measures
wall-clock time, which is appropriate for web services, not processor time,
which might be appropriate for limiting other calls.

Also note that this leaves the big question of how to cleanup when the call
goes over its limit. In order to truly return to a known state, you'll have
to exit the process, and in some cases even that may not be enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top