asynchronous - Calling a WCF asynchronously from an ASP.NET MVC application -
i have established n-tiered asp.net mvc application synchronously; controllers inherit controller rather asynccontroller.
what want take 1 of lower tiers (that literally every flow consumes) , put in awaited call wcf. why await? well, figure reduce overall thread-count , make server more scalable.
however, not in position change of code outside of tier. normally, 1 change calling methods returning t return 'async task', , give method name "async" suffix, e.g.:
from
public string getdata()
to
public task<string> getdataasync()
okay, went following (cut down) code:
public responseobject getsomething(requestobject request) { return mymethodasync(request).result; } private static async task<responseobject> mymethodasync(requestobject request) { using (var client = new client(new nettcpbinding(), new endpointaddress(url)))) { await client.dosomething(request).configureawait(true); } }
when run code (f5), gets line calls "await client.dosomething(request).configureawait(true);" , then, unfortunately, that's last see of thread. occassionally return when i'm debugging (f11), 99% of time doesn't.
the non-async method works fine
debugging wcf service shows receives request, processes , returns
using console app, works perfectly. it's when try in 1 of "middle" tiers of web application thread disappears.
i've tried .configureawait(true) , .configureawait(false).
short answer: don't block on async code (your problem's .result
blocks, while task
concurrent one, not parallel one)
long answer (and reading, too): don't block on async code
Comments
Post a Comment