Geeks With Blogs

Hani Amr


I had a problem in one of the tasks, that is when using callbacks with WCF service sometimes the callback faults and causes your service to hang or timeout the request.

The solution to this was to callback your client in a different thread and catch the exception, and then return it to the application in a nice way.

Here's an example for this:

private void YourMethod()


   //... Do work

   //Time to callback one of the clients


BackgroundWorker workerThread = new BackgroundWorker();

workerThread.DoWork += new DoWorkEventHandler(workerThread_DoWork);




void workerThread_DoWork(object sender, DoWorkEventArgs e)


ICallBackContract callback = e.Argument as ICallBackContr







   //Do your error handling then





Posted on Tuesday, April 24, 2012 10:54 AM WCF | Back to top

Copyright © H@Ni | Powered by: