473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

exception pause

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
2 1563
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew | last post by:
When will .NET have a low-pause-time garbage collector A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have...
11
by: Paminu | last post by:
Is there something like system("PAUSE") for linux?
2
by: Robert A. van Ginkel | last post by:
I have a strange C# problem. Is the following a bug? Because it should be possible to run unsafe code. How can I accomplish this? And where can I read more about this, because documentation on this...
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
11
by: Marek | last post by:
What can I do in order to avoid first exception pause? I am sure everyone already experienced this behavior and there must be a solution. regards
3
by: Andreas | last post by:
Hi NG, i encountered a problem during developing some activex control with c#. I read an article that it is possible to expose windows forms as activex controls. So I tried it and it worked...
38
by: Jackie | last post by:
I just want the programme to stop for a while. Thanks.
2
by: shumaker | last post by:
We are new to using the Tests in VS 2005, and they are really great, but we are having a problem with them in regards to exceptions. Any many cases when we are debugging code we would like...
2
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.