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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:05:44+00:00 2026-05-23T05:05:44+00:00

I have a test web service that I am calling asynchronously. I am surprised

  • 0

I have a test web service that I am calling asynchronously. I am surprised that it appears to work fine even though there is a (non-lazy) singleton in which the get method does not have a lock.

For example, my web service has a singleton that has a Get method (without a lock) that calls a previously set Factory, the factory then instantiates a new object from a pre-set detail object and returns the new object.

So the code would proceed as follows:

MethodCalledFromSingleton{
    Instantiate Obj A
    Use stored object to set properties of Obj A
    Instantiate Object B
    Assign Object B to a property of Object A
    Return Object A
}

In an explicitly multi-threaded environment, one thread could instantiate the object, then before it returns, another thread could instantiate another object, then both return. Couldn’t both threads then point to the same reference?

However, as I said, I am not experiencing any problems, so do asynchronous web service calls conceptually work in a different way compared to explicitly threading the code?

  • 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-23T05:05:45+00:00Added an answer on May 23, 2026 at 5:05 am

    It depends on what kind of asynchronous calls you are using. If you are using the event-based asynch pattern, synchronization is done automatically so that the completed event is run on the same thread that initiated the call.

    I haven’t been able to find reliable documentation on it, but it is the behaviour I found out when digging into it, see What thread calls the completed event handler on silverlight WCF calls?.

    Edit

    Documentation validating that the completed event is called on the right thread can be found in the "Threading and Contexts" section of http://msdn.microsoft.com/en-us/library/ms228974.aspx.

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

Sidebar

Related Questions

I have a test web service replicating a live web service that hasn't been
I have a web service that I created in C# and a test harness
I have a web service that needs different settings for different environments (debug, test,
I have a simple web service that uses an oracle database. When I test
I have (after quite a bit of work) a web test that will upload
I have a peculiar problem when calling a web service that expects the message
I have a web service that I am trying to test in Visual Web
I have a web service I'm trying to load test. I created a program
I have created a Visual Studio 2008 sp1 test suite web test that uploads
I have a web service that I have published locally. I wrote an HTML

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.