Saint
Saint

Reputation: 5469

WCF Service: Asynchronous method or BackgroundWorker

If some method takes a lot of time, should I implement it as asynchronous?

Or maybe use synchronous in another Thread (e.g. using BackgroundWorker)?

Upvotes: 1

Views: 1150

Answers (1)

Vinoth
Vinoth

Reputation: 2439

Asychronous calling is used when you have work items that should be handled in the background and you care when they finish

Use BackgroundWorker if you have a single task that runs in the background and needs to interact with the UI. and use it if you don't care when they finish their task. The task of marshalling data and method calls to the UI thread are handled automatically through its event-based model.

Avoid BackgroundWorker if (1) your assembly does not already reference the System.Windows.Form assembly, (2) you need the thread to be a foreground thread, or (3) you need to manipulate the thread priority.

Upvotes: 4

Related Questions