title: Does WCF Service use multiple threads to process incoming requests?
body: <p>How can I ensure that a WCF service uses threads from a ThreadPool to process incoming messages? </p>
  
  <p><strong>At the moment simple method invocation like 'return null;' takes about 45 seconds while another requests are processing</strong></p>
  
  <p>Here is how I have annotated my service class:</p>
  
  <pre><code>[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
      public partial class MyService : IMyService {
  ...
  }
  </code></pre>
  
  <p>But when I'm watching the process in task manager it seems to be using a constant number of threads. Even under load.</p>
  
  <hr>
  
  <pre><code>public ActionResult SelectDatabase(string param)
          {
              if (!String.IsNullOrEmpty(param))
              {
              try
              {
                  MyServicece svc = new MyService();
                  Database[] dbsArray = svc.GetDatabases(param);
                  if (depsArray != null)
                      ViewData["depsArray"] = depsArray;
  
                  return View();
              }
              catch (Exception exc)
              {
                  // log here                
                  return ActionUnavailable();
              }
          }
  </code></pre>
  
  <p>Here is my service behavior:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;runtime&gt;
  
    &lt;/runtime&gt;
    &lt;system.net&gt;
      &lt;connectionManagement&gt;
        &lt;add address="*" maxconnection="100" /&gt;
      &lt;/connectionManagement&gt;
    &lt;/system.net&gt;
    &lt;system.serviceModel&gt;
      &lt;diagnostics performanceCounters="Default" /&gt;
      &lt;bindings&gt;      
        &lt;netTcpBinding&gt;
          &lt;binding sendTimeout="00:02:00" receiveTimeout="00:02:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"&gt;
            &lt;security mode="None"&gt;           
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/netTcpBinding&gt;
      &lt;/bindings&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="CrossDomainServiceBehavior"&gt;
            &lt;webHttp /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="MyService.MyServiceBehavior"&gt;
            &lt;serviceThrottling maxConcurrentCalls="100"   maxConcurrentInstances="100" maxConcurrentSessions="100" /&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483646"/&gt;
            &lt;serviceMetadata httpGetEnabled="false" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="MyService.MyServiceBehavior" name="MyService.MyService"&gt;
          &lt;endpoint address="MyService" binding="netTcpBinding" contract="AService.IAServ"  isSystemEndpoint="false" /&gt;
          &lt;endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
        &lt;service behaviorConfiguration="MyService.MyServiceBehavior" name="MyService.MyServiceAdmin"&gt;
          &lt;endpoint address="MyServiceAdmin" binding="netTcpBinding" contract="MyService.IMyServiceAdmin"  isSystemEndpoint="false" /&gt;
          &lt;endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /&gt;        
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
  &lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;&lt;/startup&gt;&lt;/configuration&gt;
  </code></pre>
  
  <hr>
  
  <p>Here is how I create service instance:</p>
  
  <pre><code>ServiceHost myserviceHost = new ServiceHost(typeof(MyService), new Uri(String.Format("net.tcp://{0}/", _bindAddress)));
              myserviceHost.Open();
              Console.WriteLine(myserviceHost.BaseAddresses[0]);
  </code></pre>