I need to make a COM call and just wait until the call returns. If the call does not return in x seconds, I want to end the request.
Create Threadto make a call.
string output = null;
Thread t = new Thread(() => { output = SomeHelper.DoWork(); });
t.Start();
t.Join(timeout);
if (string.IsNullOrEmpty(output))
this.Send500();
The method that completes the response.
protected void Send500()
{
Response.ClearHeaders();
Response.ClearContent();
Response.Status = "500 ServiceUnavailable";
Response.StatusCode = 500;
Response.Flush();
Response.SuppressContent = true;
Response.End();
}
When it works Response.End(), I get an error Thread was being aborted. It is expected. I'm fine with a mistake. This is normal for what I'm trying to do.
Is there any other reason for concern when this error returns, which I should know about?
source
share