Reputation: 1793
here is my code ashx http handler which send something to client based on request.
public void ProcessRequest(HttpContext context)
{
string startQstring = context.Request.QueryString["start"];
string nextQstring = context.Request.QueryString["next"];
//null check
if ((!string.IsNullOrWhiteSpace(startQstring)) &&
(!string.IsNullOrWhiteSpace(nextQstring)))
{
//convert string to int
int start = Convert.ToInt32(startQstring);
int next = Convert.ToInt32(nextQstring);
//setting content type
context.Response.ContentType = "text/plain";
DataClass data = new DataClass();
//writing response
context.Response.Write(data.GetAjaxContent(start, next));
}
}
it is working but i am not sure that does it handle multiple request at a time like 1000 request serving at a time. if not then tell me best way to write code in such way which can handle multiple request at the same time in efficient way. thanks
Upvotes: 0
Views: 1549
Reputation: 120450
Looks good, but if your DataClass instance writes to any shared state, there might be a problem.
Upvotes: 1
Reputation: 1038820
Everything will depend on the implementation of the GetAjaxContent
method on your DataClass
. If this method doesn't rely on some shared state and it is thread safe your code should be able to handle multiple clients concurrently. Because you are using only local variables (except the GetAjaxContent
method for which we cannot know what it does) your code is thread safe.
Upvotes: 1