I have a windows client that calls web service 1 (Broker) synchronously, web
service 1 then calls web service 2 (Service) asynchronously, web service 2
sleeps its thread for 10 seconds. When I put a stopwatch on the windows
client the call to web service 1 takes a fraction over 10 seconds. What I
would think would happen is that I would get a return from web service 1
alsmost instantly. When I attach the debugger to web service 1, I even see
the return statement get hit instantly, yet the response waits until the
callback is complete. I want the answer to the client not wait for web
service 2 to complete.
-Can anyone help me understand why the call from the client takes 10 seconds
and is not "instant"?
-Is there any way to make the response to the client without waiting for the
callback?
Here is the relevant code:
Client making synchronous call (Broker is a proxy class generated by
wsdl.exe):
private void button3_Click(object sender, EventArgs e)
{
sw = new Stopwatch();
sw = Stopwatch.StartNew();
Broker broker = new Broker();
string temper = broker.SubmitReport("reportingData");
sw.Stop();
TimeSpan ts = sw.Elapsed;
String elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
MessageBox.Show(elapsedTime);
}
Here is the Broker code (Service is a proxy class generated by wsdl.exe)
[WebMethod]
public string SubmitReport(string reportData)
{
Service reporter = new Service();
reporter.GenerateReportCompleted += new
GenerateReportCompletedEventHandler(reporter_Gener ateReportCompleted);
reporter.GenerateReportAsync(reportData);
return reportData;
}
void reporter_GenerateReportCompleted(object sender,
GenerateReportCompletedEventArgs e)
{
string test = "test";
}
Here is the Service code:
[WebMethod]
public string GenerateReport(string reportingData)
{
System.Threading.Thread.Sleep(10000);
return waiter(reportingData);
}
As a note, I tried a counter as well becuase I thought the Sleep may be
sleeping the thread that Broker was running on.
DAvid