开发者

WCF Service call another service in background

I want to call a web service from another web service in a non-blocking way. I've implemented this by using BackgroundWorker. But, I'm not sure whether this is the best way to do.

Scenario: I call a web service Service_A which performs certain task & has to inform another web service Service_B about the changes made. I call the Service_B's one-way function NotifyUpdates for handling the updates. Service_A doesn't waits for Service_B's response & continues with its task. The response from the Service_B is logged in the background.

My questio开发者_JAVA技巧n is, what is the best way to do it?

Thanks.


BackgroundWorker is purposed for UI use, and I don't think it's the best way to use it here.

If you are using .Net 4 better to use Task

var t = Task.Factory.StartNew(() => DoServiceBCall());

If not,use ThreadPool.QueueUserWorkItem or Thread

ThreadPool.QueueUserWorkItem(new WaitCallback(DoServiceBCall));

Hope this helps


First of all, based on your scenario, if call to Service B is one way, Service A will not receive any response from Service-B except Http Status code (if call to service-B is on Http).

I'd call Service-B asynchronously to keep the things and code simple.

HTH, Amit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜