By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

exception pause

P: n/a
I'm having a problem in that the first time an exception is thrown in
my app, there is about a 2 second pause. After that first time,
subsequent exceptions go very quickly. This pause is really annoying
the users who think the application is having problems, is there any
way I can make it not happen?

further, the reason this is happening is that I'm trying to test a
class to see if that class implements a certain interface. I'm not
sure how to do that without doing a

IMyInterface imyint = (IMyInterface)someclass;

and doing this will always throw an exception if the class doesn't
implement the exception.

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
allen <al***@sparkysystems.com> wrote:
I'm having a problem in that the first time an exception is thrown in
my app, there is about a 2 second pause. After that first time,
subsequent exceptions go very quickly. This pause is really annoying
the users who think the application is having problems, is there any
way I can make it not happen?
I've only seen this happen in a debugger. Are your users running your
app in the debugger?

If not, could you post a short but complete program which demonstrates
the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
further, the reason this is happening is that I'm trying to test a
class to see if that class implements a certain interface. I'm not
sure how to do that without doing a

IMyInterface imyint = (IMyInterface)someclass;

and doing this will always throw an exception if the class doesn't
implement the exception.


Use the "is" or "as" operators:

IMyInterface imyint = someclass as IMyInterface;
if (imyint != null)
{
....
}

or

if (someclass is IMyInterface)
{
IMyInterface imyint = (IMyInterface) someclass;
...
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

P: n/a
you are absolutely correct on both points. Thanks for pointing that
out, that helped me a great deal.

On Wed, 16 Mar 2005 07:27:12 -0000, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
allen <al***@sparkysystems.com> wrote:
I'm having a problem in that the first time an exception is thrown in
my app, there is about a 2 second pause. After that first time,
subsequent exceptions go very quickly. This pause is really annoying
the users who think the application is having problems, is there any
way I can make it not happen?


I've only seen this happen in a debugger. Are your users running your
app in the debugger?

If not, could you post a short but complete program which demonstrates
the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
further, the reason this is happening is that I'm trying to test a
class to see if that class implements a certain interface. I'm not
sure how to do that without doing a

IMyInterface imyint = (IMyInterface)someclass;

and doing this will always throw an exception if the class doesn't
implement the exception.


Use the "is" or "as" operators:

IMyInterface imyint = someclass as IMyInterface;
if (imyint != null)
{
...
}

or

if (someclass is IMyInterface)
{
IMyInterface imyint = (IMyInterface) someclass;
...
}


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.