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 7852567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:27:18+00:00 2026-06-02T19:27:18+00:00

I have an Unhandled Exception handler that does something like this: AddHandler Application.ThreadException, AddressOf

  • 0

I have an Unhandled Exception handler that does something like this:

  AddHandler Application.ThreadException, AddressOf Application_ThreadException

I was looking at what exactly this means and noticed that the decompiled code for Application shows:

        /// <include file='doc\Application.uex' path='docs/doc[@for="Application.ThreadException"]/*' />
        /// <devdoc> 
        ///    <para>Occurs when an untrapped thread exception is thrown.</para>
        /// </devdoc>
        public static event ThreadExceptionEventHandler ThreadException {
            add { 
                Debug.WriteLineIf(IntSecurity.SecurityDemand.TraceVerbose, "AffectThreadBehavior Demanded");
                IntSecurity.AffectThreadBehavior.Demand(); 

                ThreadContext current = ThreadContext.FromCurrent();
                lock(current) { 
                    current.threadExceptionHandler = value;
                }
            }
            remove { 
                ThreadContext current = ThreadContext.FromCurrent();
                lock(current) { 
                    current.threadExceptionHandler -= value; 
                }
            } 
        }

So it looks like from the “add” that the last person that subscribes to Application.ThreadException is the one who gets it (it’s not additive as most event handlers are). I don’t want to give up my subscription to this eventhandler no matter what. Can anyone think of a way that I could track when I lose my subscription to the Application.ThreadException so I can steal it back from whoever stole it from me?

  • 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-06-02T19:27:20+00:00Added an answer on June 2, 2026 at 7:27 pm

    I am thinking maybe I can do this with a Timer. Check if someone is already subscribed to this event and it is not me then re-subscribe. I know this is a little hackey… just thinking…

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

Sidebar

Related Questions

I have a global exception handler hooked up to Application.ThreadingException and this works fine
I have just discovered the nifty unhandled exception handler for cocoa-touch. Now that I
Say I have something like this, which sends unhanded exceptions to logging.critical() : import
In my 3.5 .net web application I have a background thread that does a
Does ASP.NET execute the Page_Unload handler regardless of an unhandled exception during page execution,
Question I have a third-party DLL that throws an unhandled exception when attempting to
This is odd. I have a WPF application that works just fine in XP
I have an unhandled exception handler. It shows a nice GUI and allows users
have a php code like this,going to convert it in to C#. function isValid($n){
Have data that has this kind of structure. Will be in ascending order by

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.