I am currently using IsAsyncPattern = true & Begin/End to implement the service operation asyncronously so the thread is not blocked for long running calls.
Is there an example implementation of how to implement service side operations asynchronously with C3 async CTP?
first you need an async service operation to call from the wcf. what is this service? some database calls (not linq nor EF) supoort async, and network calls normally do. you can also to async i/o and timers.
Thanks for the article. Could you explain the following?
What is the advantage of writing the method following way? Task.Factory.StartNew will anyway block your threadpool thread for the duration of the longRunningOperation?
public Task<string> SampleMethodAsync(string msg)
This is what I get when I try to generate the proxy from visual studio....do i need to use some switch and do it manually using svcutil?
Type 'System.Threading.Tasks.Task`1[System.String]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
trsuman
Member
13 Points
10 Posts
Async Operations with WCF
Nov 24, 2011 02:52 AM|LINK
I am currently using IsAsyncPattern = true & Begin/End to implement the service operation asyncronously so the thread is not blocked for long running calls.
Is there an example implementation of how to implement service side operations asynchronously with C3 async CTP?
bruce (sqlwo...
All-Star
36836 Points
5443 Posts
Re: Async Operations with WCF
Nov 26, 2011 09:46 PM|LINK
first you need an async service operation to call from the wcf. what is this service? some database calls (not linq nor EF) supoort async, and network calls normally do. you can also to async i/o and timers.
trsuman
Member
13 Points
10 Posts
Re: Async Operations with WCF
Nov 28, 2011 05:30 PM|LINK
The service calls another external services and database. Is there an example anywhere?
PiyushJo
Member
64 Points
17 Posts
Re: Async Operations with WCF
Nov 30, 2011 12:52 AM|LINK
My colleague Howard (http://codebetter.com/howarddierking/) is going to blog about the server side async support in WCF 4.5 so stay tuned.
hdierking
Member
19 Points
3 Posts
Re: Async Operations with WCF
Nov 30, 2011 06:54 PM|LINK
I've added a post with sample code at http://codebetter.com/howarddierking/2011/11/30/building-an-async-wcf-service-in-net-4-5/
trsuman
Member
13 Points
10 Posts
Re: Async Operations with WCF
Dec 01, 2011 05:39 AM|LINK
Thanks a lot
trsuman
Member
13 Points
10 Posts
Re: Async Operations with WCF
Dec 03, 2011 12:15 AM|LINK
Hi Hdierking,
Thanks for the article. Could you explain the following?
What is the advantage of writing the method following way? Task.Factory.StartNew will anyway block your threadpool thread for the duration of the longRunningOperation?
public Task<string> SampleMethodAsync(string msg)
{
return await Task.Factory.StartNew(() => {
longRunningOperation();
return "hello " + msg;
});
}
I have posted the same on your blog.
How do you run the longRunningOperation(either a service or db call) and not block your thread pool thread?
trsuman
Member
13 Points
10 Posts
Re: Async Operations with WCF
Dec 03, 2011 12:32 AM|LINK
This is what I get when I try to generate the proxy from visual studio....do i need to use some switch and do it manually using svcutil?
Type 'System.Threading.Tasks.Task`1[System.String]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.