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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:58:35+00:00 2026-05-13T14:58:35+00:00

I noticed in System.Threading.TimerBase.Dispose() the method has a try{} finally{} block but the try{}

  • 0

I noticed in System.Threading.TimerBase.Dispose() the method has a try{} finally{} block but the try{} is empty.

Is there any value in using try{} finally{} with an empty try?

http://labs.developerfusion.co.uk/SourceViewer/browse.aspx?assembly=SSCLI&namespace=System.Threading&type=TimerBase

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal bool Dispose(WaitHandle notifyObject)
{
    bool status = false;
    bool bLockTaken = false;
    RuntimeHelpers.PrepareConstrainedRegions();
    try {
    }
    finally {
        do {
            if (Interlocked.CompareExchange(ref m_lock, 1, 0) == 0) {
                bLockTaken = true;
                try {
                    status = DeleteTimerNative(notifyObject.SafeWaitHandle);
                }
                finally {
                    m_lock = 0;
                }
            }
            Thread.SpinWait(1);
            // yield to processor
        }
        while (!bLockTaken);
        GC.SuppressFinalize(this);
    }

    return status;
}
  • 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-13T14:58:35+00:00Added an answer on May 13, 2026 at 2:58 pm

    From http://blog.somecreativity.com/2008/04/10/the-empty-try-block-mystery/:

    This methodology guards against a
    Thread.Abort call interrupting the
    processing. The MSDN page of
    Thread.Abort says that “Unexecuted
    finally blocks are executed before the
    thread is aborted”. So in order to
    guarantee that your processing
    finishes even if your thread is
    aborted in the middle by someone
    calling Abort on your thread, you can
    place all your code in the finally
    block (the alternative is to write
    code in the “catch” block to determine
    where you were before “try” was
    interrupted by Abort and proceed from
    there if you want to).

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

Sidebar

Related Questions

I noticed that System.Threading.Thread implements a finalizer but not IDisposable. The recommended practice is
The only way I found so far is System.Drawing.Bitmap.GetPixel() , but Microsoft has warnings
I noticed that when overriding the System.Windows.Window OnRender method fails to draw to the
I noticed that WPF has the System.Windows.Media(.Imaging) namespaces that contain a lot of the
While looking at the source code of System.ServiceModel.Channels.BufferManager, I noticed this method: void TuneQuotas()
I recently noticed that on my system it is not possible to require 'lib/file.pl'
While following path for wait system call, noticed that before calling do_wait_thread we get
I've noticed, that sometimes (I don't know exactly when and why) system recreates my
im trying to create a badge system similar to stackoverflows. i noticed that stackoverflow
I've noticed that on most, if not all, standard web controls in the System.Web.UI.WebControls

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.