sunilkumarba
sunilkumarba

Reputation: 901

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 question is, what is the best way to do it?

Thanks.

Upvotes: 0

Views: 659

Answers (2)

amit
amit

Reputation: 2123

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

Upvotes: 0

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

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

Upvotes: 2

Related Questions