473,395 Members | 1,516 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,395 software developers and data experts.

Catching exceptions inside static callback methods

If I catch an exception in a static callback method like:

private static void ResponseCallback(IAsnycResult
asyncResult)
{
try { //code...code...code }
catch (WebException e)
{ //handle exception }
}

will that that WebException object remain for the life of
the process???

I have a windows service which makes WebRequests and uses
a callback to handle asynchronous requests, but if
there's an exception raised, I want to be able to
continue using this class later on. I've had a hard time
debugging it, but it seems like once there's an exception
raised, I keep catching an exception, even when I'm
pretty sure the request should succeed.

Does the WebException remain in memory the same as other
static members??? If so how, should this kind of
situation be coded?

Thanks

Nov 15 '05 #1
2 1790
Adam, no, that web exception will not always be in memory. It sounds like
there is something else going on with the methods which you think should be
successful. How are you doing your debugging? If you are still seing a
problem please post a complete, runnable sample that demonstrates the
problem.

--
Greg Ewing [MVP]
http://www.claritycon.com/
"Adam" <ad********@excell.com> wrote in message
news:0e****************************@phx.gbl...
If I catch an exception in a static callback method like:

private static void ResponseCallback(IAsnycResult
asyncResult)
{
try { //code...code...code }
catch (WebException e)
{ //handle exception }
}

will that that WebException object remain for the life of
the process???

I have a windows service which makes WebRequests and uses
a callback to handle asynchronous requests, but if
there's an exception raised, I want to be able to
continue using this class later on. I've had a hard time
debugging it, but it seems like once there's an exception
raised, I keep catching an exception, even when I'm
pretty sure the request should succeed.

Does the WebException remain in memory the same as other
static members??? If so how, should this kind of
situation be coded?

Thanks

Nov 15 '05 #2
Thanks Greg,

That's what I thought. Debugging is only a problem
because the problem occurs so rarely and I've been too
busy to set up a workable test bed to reproduce the
problem. I'd have to have a web site that returns a 401
access denied error, recompile etc, etc.

Posting a working version might be tricky, since I'd need
to post several classes. It's a service, but if (more
likely when) I get to that point, I'll create a paired
down version of the program. Then if I still can't
figure it out, I'll repost. Thanks again.
-----Original Message-----
Adam, no, that web exception will not always be in memory. It sounds likethere is something else going on with the methods which you think should besuccessful. How are you doing your debugging? If you are still seing aproblem please post a complete, runnable sample that demonstrates theproblem.

--
Greg Ewing [MVP]
http://www.claritycon.com/
"Adam" <ad********@excell.com> wrote in message
news:0e****************************@phx.gbl...
If I catch an exception in a static callback method like:
private static void ResponseCallback(IAsnycResult
asyncResult)
{
try { //code...code...code }
catch (WebException e)
{ //handle exception }
}

will that that WebException object remain for the life of the process???

I have a windows service which makes WebRequests and uses a callback to handle asynchronous requests, but if
there's an exception raised, I want to be able to
continue using this class later on. I've had a hard time debugging it, but it seems like once there's an exception raised, I keep catching an exception, even when I'm
pretty sure the request should succeed.

Does the WebException remain in memory the same as other static members??? If so how, should this kind of
situation be coded?

Thanks

.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steven Reddie | last post by:
I understand that access violations aren't part of the standard C++ exception handling support. On Windows, a particular MSVC compiler option enables Microsoft's Structured Exception Handling...
4
by: faktujaa | last post by:
Hi, I am having some problem with callback used in socket implementation. private static void Connect(string strPrtrIPAddr, int intPrtrPort, ref Socket rsocClient) { try { // Create remote end...
1
by: terrencel | last post by:
I was told to look at some old C code that was ported to C++. One of the file is like: ========================================= CPPClass* someCPPVar = NULL; extern "C" {
2
by: Mark Hoffman | last post by:
All, My application spawns a worker process by calling BeginInvoke with an asynchronous callback method. This callback method is responsible for calling EndInvoke. No problems there; pretty much...
5
by: Simon Tamman | last post by:
I have an object named DisasterRecovery. The Ctor of this object is this: private DisasterRecovery() { Application.ThreadException+= new...
5
by: Jon E. Scott | last post by:
I'm a little confused with "static" methods and how to access other unstatic methods. I'm a little new to C#. I'm testing a callback routine within a DLL and the callback function returns a...
1
by: Simon | last post by:
Hi all, I'm having a problem creating a global exception handler in a windows service that I'm making. Another poster suggested that the way to do this was to use the...
12
by: Karlo Lozovina | last post by:
I'm not sure if Python can do this, and I can't find it on the web. So, here it goes: try: some_function() except SomeException: some_function2() some_function3() ...
7
by: JackPot | last post by:
Actually, I'm interested in learning where the different types of exceptions are documented for a specific type of class, let us say for instance classes in the System.Net.Mail Namespace. Shouldn't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.