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

  • SEARCH
  • Home
  • 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 125221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:07:28+00:00 2026-05-11T05:07:28+00:00

concurrent colleagues. I need to be able to trap an exception that might be

  • 0

concurrent colleagues.

I need to be able to trap an exception that might be thrown from a background thread.

Let the code speak for itself (it is a bad code)

 public delegate bool CheckForUpdatesHandler(Uri uri);     public class UpdatesChecker {         public event AsyncCompletedEventHandler CheckForUpdatesAsyncCompleted;         protected virtual void OnCheckForUpdatesAsyncCompleted(AsyncCompletedEventArgs args) {             if (CheckForUpdatesAsyncCompleted != null)                 CheckForUpdatesAsyncCompleted(this, args);         }          public bool CheckForUpdates(Uri ftp) {                         Thread.Sleep(1000);             throw new Exception('bla');             return true;         }                public void CheckForUpdatesAsync(Uri ftp){                         var action = new CheckForUpdatesHandler(CheckForUpdates);             var c=action.BeginInvoke(ftp, delegate(IAsyncResult state) {                 OnCheckForUpdatesAsyncCompleted(new AsyncCompletedEventArgs(null, false, null));             }, null);         }         } 
  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T05:07:29+00:00Added an answer on May 11, 2026 at 5:07 am

    With Delegate.BeginInvoke, the exception will be retrieved by calling .EndInvoke – which you must do anyway to prevent a leak.

    With BackgroundWorker, it will appear on the completion event

    On a vanilla Thread, an unhandled exception will tear down the process.

    However, the simplest approach is: don’t let it throw…

        public bool CheckForUpdates(Uri ftp) {         try {             Thread.Sleep(1000);             throw new Exception('bla');             return true;         } catch (Exception ex) {             // raise an event, call a method/callback, do something         }     } 

    If you currently aren’t using EndInvoke, then perhaps switch to the above pattern and just use ThreadPool directly (rather than Delegate.BeginInvoke).

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

Sidebar

Related Questions

I'm using a java.util.concurrent.ExecutorService that I obtained by calling Executors.newSingleThreadExecutor() . This ExecutorService can
so that you can make your program concurrent easily in the future.
I was looking at the source code of java.uti.concurrent.locks.AbstractQueuedSynchronizer and the acquire() method looks
By default concurrent manager jobs are run under the APPS user. Is it possible
I keep on hearing about concurrent programing every where. Can you guys throw some
I'm attempting to issue two concurrent AJAX requests. The first call (/ajax_test1.php) takes a
I'm looking for a way of getting a concurrent collection in C# or at
I have some problems on a site with the concurrent access to a list.
Is there any advantage of using java.util.concurrent.CountdownLatch instead of java.util.concurrent.Semaphore ? As far as
Imagine a Java client/server ERP application serving up to 100 concurrent users, both web

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.