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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:56:54+00:00 2026-05-18T04:56:54+00:00

We have a web service that sends requests to a windows service which hosts

  • 0

We have a web service that sends requests to a windows service which hosts a WCF service for processing.

The interface is simple:

namespace MyApp
{
    [ServiceContract]
    public interface IMyApp
    {   
        [OperationContract]
        string DoSomething(string xml);
    }
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    class MyAppWcf : IMyApp
    {
        public string DoSomething(string xml) 
        { 
            Customer customer = GlobalObject.GetCustomer(xml); //millisecs 
            return customer.DoSomething(xml); //Takes 5-10 seconds
        }
    }
}

GlobalObject is instantiated on the WindowsService.OnStart() and contains all the static data the customer objects need.
The interface DoSomething() will be called up to ca. 30 different clients.

Questions:
1. What is the default threading behaviour now? Will each call have to wait until the last one is finished?
2. What effect will changing InstanceContextMode?

REAL question:
There are up to 1000 customer objects, 2 different customer objects can be called in parallel, but the same one cannot. e.g.

DoSomething(“Customer 1”); => Goes ahead. Answer in 10 seconds
DoSomething(“Customer 2”); => Goes ahead in parallel with the above call.

DoSomething(“Customer 2”); => Will wait for last call of DoSomething(“Customer 2”) to finish

What should my service behavior settings be and do I have to implement a lock mechanism to prevent the same object being processed more than once in parallel?

Thanks.

Edit 2: GlobalObject.GetCustomer() just retrieves the customer mentioned in the XML from a dictionary.

  • 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-18T04:56:55+00:00Added an answer on May 18, 2026 at 4:56 am

    OK. I’m not sure I knew that ConcurrencyMode is ignored when using PerCall instancing, but looking at my own project, I use PerCall instancing and don’t specify any value for ConcurrencyMode. So apparently, I did know this at one point and just failed to document it in my code. That is now corrected.

    My project works a lot like you’ve described yours, and I use InstanceContextMode.PerCall as I’ve already mentioned. Here’s what this means.

    • Client1 => MyAppWcfInst.DoSomething( "<customer id=A/>" );
    • Client2 => MyAppWcfInst.DoSomething( "<customer id=B/>" );
    • Client3 => MyAppWcfInst.DoSomething( "<customer id=B/>" );

    All three clients will interact with your WCF service simultaneously, but each of them will have its own instance and operate within a separate thread. So while each call by each client is single-threaded, they can be active at the same time. This means that the list of Customer objects can be accessed by multiple clients at the same time.

    Client1 and Client2 can be operating in parallel since they deal with different Customer objects, but Client3 needs to wait until Client2 is finished before it can “do something” with CustomerB. All this means is that you need to synchronize access within each Customer object. In other words, the logic inside the Customer.DoSomething() method needs to have a synchronization lock to prevent multiple clients from operating on the Customer at the same time.

    class Customer
    {
        private object _sync = new object();
    
        public string DoSomething( string xml )
        {
            lock (_sync)
            {
                // put your logic here...
            }
        }
    }
    

    This is the way my WCF service works. Hope this helps.

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

Sidebar

Related Questions

I have a .NET Windows Service which spawns a thread that basically just acts
I have a web service that receives requests from users and returns some json.
Assume I have a RESTful web service, which holds information about an object that
I have a web service that requires special headers to be sent in the
I have a web service that stores data in a local SQL Server 2008
I have a web service that is running on IIS (6 or 7, doesn't
I have a web service that takes a byte[] and saves it. This works
I have a web service that serves widgets. It is hosted on a server
I have a web service that wish to call, and I want to pass
I have a web service that uses nhibernate, calls to the web service go

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.