Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Sun, 8 Jun 2008 05:33:00 -0700,    group: microsoft.public.windows.developer.winfx.indigo        back       


Asynchronous WCF Question   
Hi
I am using WCF Services exposed as REST URIs to be consumed by generic AJAX 
clients. All of my services need to be Async in nature.
We have a typical n-layer architecture for our project wherein the Service 
Layer --> Business Layer and
Business Layer --> Data Access Layer
Data Access Layer --> LINQ --> DB

The heaviest part of the processing will be fetching and sending updates to 
the database. As such this part needs to be made asynchronous.
Earlier, we had thought that the service layer would simply accept the 
calls. It would then use ThreadPool.QueueUserWorkItem to spawn a secondary 
thread and move the calls to the Business Layer onwards to this secondary 
thread. For e.g.

public IAsyncResult BeginGetData(params)
{
     //Create an AsyncResult
     ThreadPool.QueueUserWorkItem(SomeCallback, AsyncResult)
    //Return AsyncResult
}

private void SomeCallback(object state)
{
     //Call BUSINESS Layer which calls Data Access Layer and so on.
}

public string GetData(AsyncResult)
{
 
}
But this defeats the purpose of Async operations since we end up using 
threads from the same thread pool as ASP.Net for the WCF services. A load 
test confirmed this too. The performance was worse than a synchronous WCF 
service call. An article I read on Async HTTP handlers mentioned the same. Do 
I need to split my Business Layer and Data Access Layer methods into Begin 
and End pairs too? Or is there a better way.

Kindly let me know, what is the preferred way of handling this as I am sure 
that this would be a problem faced commonly.

Thanks in advance
Vikas Manghani
date: Sun, 8 Jun 2008 05:33:00 -0700   author:   Vikas Manghani

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us