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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:59:43+00:00 2026-05-22T11:59:43+00:00

I would like to understand the ServiceBehavior.ConcurrencyMode property. Consider the following code on service

  • 0

I would like to understand the ServiceBehavior.ConcurrencyMode property.

Consider the following code on service side:

[ServiceContract]
public interface IMySercice {
   [OperationContract]
   int mycall(int a);
}
/*** HERE I WILL GENERATE Two variants of this code ***/
[ServiceBehaviour(InstanceContext = InstanceContextMode.Single)]
public class MyService : IMyService {
   // Constructors...
   // implementations of interface
   public int mycall(int a) { ... }
}
class Program {
   static void Main(string[] args) {
      MyServiceMyS = new MyService(...); /* Creating service instance */
      Uri MyUri = new Uri("http://services.mycompany.com/services/"); /* Base address for my hosted service */
      using (ServiceHost host = new ServiceHost(MyS)) { /* Defining service host, configuration file contains info regarding endpoints, not shown here for clarity */
         host.Start();
         host.Stop();
      }
   }
}

Now consider that I would like to call this service, please consider 10 machines in the web that may call my service.
At a certain point, it happens that these 10 machines ALL MAKE 10 simultaneous requests for int mycall(int a).
I would like to examine these scenarios:

SCENARIO 1

...
/*** VARIANT 1 ***/
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContext = InstanceContextMode.Single)]
public class MyService : IMyService {
   ...
}
...

SCENARIO 2

...
/*** VARIANT 2 ***/
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContext = InstanceContextMode.Single)]
public class MyService : IMyService {
   ...
}
...

So, 10 simultaneous calls arrive… what does it happen in both cases? Please tell me whether I am right or wrong:

In Scenario 1, single threaded, these 10 calls are queued and executed one at a time. My service (THE SAME INSTANCE OF MY SERVICE)’s method will be called ten times in sequence. In Scenario 2, multiple threaded, WCF will cause 10 threads to simultaneously call my service method.

Is it true what I said?
Thanks

  • 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-22T11:59:44+00:00Added an answer on May 22, 2026 at 11:59 am

    In both scenarios all 10 clients will be served in parallel by 10 different threads. The reason is that ConcurrencyMode setting is dependent on InstanceContextMode setting. InstanceContextMode defines how WCF engine servers client requests – how is new instance of the service created if request arrives:

    • PerCall – each request is served by a new instance of the service
    • PerSession – all request from single proxy instance are served by the same service instance
    • Single – per host singleton – all request are served by the same instance of the service

    So your description will be correct if you also use InstanceContextMode.Single but default value is PerCall for bindings not supporting sessions (basicHttpBinding, webHttpBinding, wsHttpBinding without security context or reliable session) or PerSession for bindings supporting sessions (netTcpBinding, netNamedPipeBinding, wsHttpBinding in default configuration using security context).

    ConcurrencyMode defines how can an instance of the service be used if multiple requests want to access it. For example PerCall instancing with Multiple concurrency is the same as Single concurrency because each instance is used to serve exactly one request regardless the concurrency setting.

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

Sidebar

Related Questions

Conceptually, I would like to accomplish the following but have had trouble understand how
Conceptually, I would like to accomplish the following but have had trouble understand how
I would like to know and understand the steps involved in fetching mail from
I would like to know this to understand why some games like Mario is
I would like to understand how symbolic debuggers work?. What are debug symbol table
I would like to understand that what is Mesh Object and its conection with
I would like to understand this error I'm getting on a SQL Server 2005
I would like to understand what is going on in the GCC runtime in
I would like to understand the difference between the Boolean and boolean types in
I would like to understand garbage collection in objective-c. I know how to work

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.