May 14th, 2012, 12:17 AM
Stop main thread untill WCF Call returns
I am new to web services and started out with WCF. I have multiple web service calls,each of which are done asynchronouslly. But my problem is that the main thread should stop untill all the web service calls return and when all the web service calls return only then it should proceed.Below is my sample code :
ServerMonitoringBoardDataService.ServerMonitoringBoardDataServiceClient c = new ServerMonitoringBoardDataService.ServerMonitoringBoardDataServiceClient();
c.GetEnvironmentAndServersCompleted += new EventHandler<ServerMonitoringBoardDataService.GetEnvironmentAndServersCompletedEventArgs>(c_GetEnvironmentAndServersCompleted);
void c_GetEnvironmentAndServersCompleted(object sender, ServerMonitoringBoardDataService.GetEnvironmentAndServersCompletedEventArgs e)
var x = e.Result;
The reason I am facing problems is that,the multiple web service calls returns data as lists and I have done some operations on this data and then displayed it on the UI.The web service calls are made in a static constructor,so as to fetch the data only once and manipulate and display it many time.
But what happens is that the main thread does not stop until the data is fetched and moves onto perform the operations,where I get a Null Exception.
Can someone please look into this.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!