Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:47:24+00:00 2026-05-26T08:47:24+00:00

for example: first step:bind UnhandledException event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); second step: try {

  • 0

for example:

first step:bind UnhandledException event.

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

second step:

try
    {
       //at here,do asynchronous operation and throw a exception.
    }
catch (Exception ex)
   {
            Console.WriteLine("error");
   }

when the asynchronous operation throw a exception,the catch code it not called,just only the UnhandledException event is triggered,after end event called then exit application.

i want capture exception anything in catch statement and avoid exit application.

=======================================================

the asynchronous code is the asynchronous socket operation.in the socket asynchronous receive message event(BeginReceive,EndReceive),i throw a OverFlowException.

throw new OverflowException("chunk size too long.");

=============================================

you are right,now i capture the exception in asynchronous operation and passed it to original class(this means exception will throw on the same thread,that can try…catcy statement can was called)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:47:25+00:00Added an answer on May 26, 2026 at 8:47 am

    An asynchronous task by default will operate in a different context from the one it was instantiated in. The try/catch block is therefore not effective in this case.

    Think about it in the following way.

    Worker worker = new HouseMaid();
    try
    {
        worker.DoSomeWork();
    }
    catch(WorkerIsSickException ex)
    {
        worker.TakeMedicin();
        worker.StopWorkingAndRestForAWhile();
    }
    

    Here we see that when the worker gets sick, the work process breaks and the exception will be handeled. However, when we do:

    Worker worker = new HouseMaid();
    try
    {
        Worker otherWorker = new HouseMaidHelper();
    
        worker.DelegateWorkTo(otherWorker, CallBackWhenOTherWorkerIsDone);
    
        worker.GoOnDoSomethingElse();
    }
    catch(WorkerIsSickException ex)
    {
        worker.TakeMedicin();
        worker.StopWorkingAndRestForAWhile();
    }
    

    The work try/catch block (or safety net if you will), will only apply for the worker, not otherWorker. The otherWorker has its own scope to work in. If the other worker fails, that shouldnt mean that the worker has to take the medicine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to set/get the cookies stored at first.example while browsing second.example , I
example some array {2,8,9,10,21,32,1,6,3...} first child take (data size / 2) and sort second
I'm taking my first step of a thousand miles with the new local storage
For example: First, say I have a Silverlight app with Windowless=true so that I
When attempting to run the first example in the boost::mpi tutorial , I was
I have a simple marker annotation for methods (similar to the first example in
Is there any Java library that supports hierarchical column? For example (the first three
Could someone explain this (strange) behavior? Why is the length in the first example
Jeff's recent article linked to a time management example of the First Fit Decreasing
I have a simple question related to one-line programming. First an example: function test(a)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.