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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:06:12+00:00 2026-05-10T21:06:12+00:00

I have an ASP.NET webpage running under IIS that uses a common assembly that

  • 0

I have an ASP.NET webpage running under IIS that uses a common assembly that contains a singleton class. Should I implement a locking mechanism on the singleton to make it thread-safe? Or, will any connection to the webserver use the same instance of the singleton?

Hopefully I’m asking this coherently.

  • 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. 2026-05-10T21:06:13+00:00Added an answer on May 10, 2026 at 9:06 pm

    The usual pattern for .NET singletons creates a single instance per app domain. The usual situation in asp.net is that you have multiple threads running through the same app domain. This means you could very well have multiple threads running code in your singleton at the same time.

    You have to examine the singleton and determine (to the best of your abilities koffreflectorkoff) if it is thread safe or not. If it keeps and modifies shared resources, or if it encapsulates some kind of state which is stored between method calls, be careful.

    You might want to wrap the singleton within a second singleton which uses locks before delegating its calls to the one you don’t have control over. That way you could have finer control over locking rather than block every call to the singleton using a single lock. It would also give you the benefit of centralizing the location of the threading code…

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

Sidebar

Related Questions

Scenario: You have an ASP.Net webpage that should display the next image in a
I have an ASP.NET 2.0 (C#) webpage with a link that pulls a blob
I have an ASP.NET webpage that displays steps that must be performed server side.
I have an asp.net webpage with a drop down menu that is populated by
I have an ASP.net page. When I am closing the webpage I need to
We have an advanced webpage (ASP.NET, C#), and a application which needs to be
I have an ASP.NET web page that displays a variety of fields that need
I have an asp.net web page with a ton of code that is handled
The Scenario: I have an ASP.Net webpage which I intend to use for letting
Here's the scenario: I have an asp.net webpage which displays dynamic data in 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.