Why are these asynchronous RIA Service calls made sequentially on the web server?

I call the RIA service method ImportSubcomponentFileSetFiles (which is Invoke, not Query) twice as follows:

foreach (var viewModel in FileSetViewModels.Where(vm => vm.IsSelectedForImport))
{
    DomainContext.ImportSubcomponentFileSetFiles(viewModel.SubcomponentFileSet.Id, callback =>
                {
        //...
        DomainContext.Load(DomainContext.GetSubcomponentFileSetWithStatusQuery(subcomponentFileSetId), LoadBehavior.RefreshCurrent,
                            callback2 =>
        {
            //...
        }, true);
    }, null);
}

In Fiddler, I see that two requests go to ImportSubcomponentFileSetFiles at once.

ImportSubcomponentFileSetFiles takes ~ 15 seconds. The first call returns after about 15 seconds, and the second call returns after 15 seconds. I can see from registration that the second call to ImportSubcomponentFileSetFiles does not start until the completion of the first call.

My question is: why are these asynchronous requests processed sequentially on the server and how can I process them in parallel?

ADDITIONAL INFORMATION

  • Ria's WCF services are hosted in an ASP.NET web application.
  • I do not store anything in the session.
  • Entity Framework 4 .
  • Domain Services LinqToEntitiesDomainService <MyObjectContext>

:

public void ImportSubcomponentFileSetFiles(int subcomponentId)
{
    Debug.WriteLine("{0}: {1} - ImportSubcomponentFileSetFiles method started", subcomponentId, DateTime.Now);

    //...code for fetching subcomponentFileSet

    subcomponentFileSet.ImportFiles(ObjectContext);

    Debug.WriteLine("{0}: {1} - ImportSubcomponentFileSetFiles method finished", subcomponentId, DateTime.Now);
}

, , :

File Set A: 27/1/2011 11:20:06 PM 11:20:06 PM - Calling ImportSubcomponentFileSetFiles (Silverlight Client)
File Set A: 27/1/2011 11:20:06 PM 11:20:06 PM - ImportSubcomponentFileSetFiles Called (Silverlight Client)
File Set B: 27/1/2011 11:20:06 PM 11:20:06 PM - Calling ImportSubcomponentFileSetFiles (Silverlight Client)
File Set B: 27/1/2011 11:20:06 PM 11:20:06 PM - ImportSubcomponentFileSetFiles Called (Silverlight Client)
File Set A: 01/27/2011 23:20:06 - ImportSubcomponentFileSetFiles method started (Server)
File Set A: 01/27/2011 23:20:06 - ImportFiles Started (Server)
File Set A: 01/27/2011 23:20:23 - ImportFiles Finished (Server)
File Set A: 01/27/2011 23:20:23 - ImportSubcomponentFileSetFiles method finished (Server)
File Set A: 27/1/2011 11:20:23 PM - Import callback recieved (Silverlight Client)
File Set A: 01/27/2011 23:20:23 - GetSubcomponentFileSetWithStatus Started (Server)
File Set A: 01/27/2011 23:20:23 - GetSubcomponentFileSetWithStatus Finished (Server)
File Set B: 01/27/2011 23:20:23 - ImportSubcomponentFileSetFiles method started (Server)
File Set B: 01/27/2011 23:20:23 - ImportFiles Started (Server)
File Set A: 27/1/2011 11:20:23 PM - Refresh callback recieved (Silverlight Client)
File Set B: 01/27/2011 23:20:36 - ImportFiles Finished (Server)
File Set B: 01/27/2011 23:20:36 - ImportSubcomponentFileSetFiles method finished (Server)
File Set B: 27/1/2011 11:20:36 PM - Import callback recieved (Silverlight Client)
File Set B: 01/27/2011 23:20:36 - GetSubcomponentFileSetWithStatus Started (Server)
File Set B: 01/27/2011 23:20:36 - GetSubcomponentFileSetWithStatus Finished (Server)
File Set B: 27/1/2011 11:20:36 PM - Refresh callback recieved (Silverlight Client)

Cheers,

+2
2

, LinqToEntitiesDomainService WCF, ServiceBehaviour ( config):

ServiceBehaviourAttribute.InstanceContextMode:

PerSession - ,

ServiceBehaviourAttribute.ConcurrencyMode:

Single.

ConcurrencyMode Single , . Multiple , . .


:

InstanceContextMode PerSession, ConcurrencyMode Single, - . - , . , , , , . , , .

, -, silverlight?

+3

/ , RIA (ImportSubcomponentFileSetFiles), - Fiddler, , , ,

ASP.NET . ASP.NET , ( /) ( ).

+1

Source: https://habr.com/ru/post/1794372/


All Articles