I want retrieve data from aspx page. But, waiting data in static field if filling.
JQuery :
$.ajax({
url: "Services/JSON/GetMessage.aspx",
type: "GET",
dataType: "json",
success: function (response) { alert(response.Text); },
error: function (x, t, m) {
if (t === "timeout") {
alert("got timeout");
} else {
alert(t);
}
}
})
Services/JSON/GetMessage.aspx
<%@ Page Language="C#" %>
<%
Response.Clear();
Response.ContentType = "text/json";
int tryCount = 0;
while (1 == 1)
{
if (ClsStaticFields.Messages.Count > 0)
{
foreach(string message in ClsStaticFields.Messages) {
Response.Write("{ Text:'" + message + "' }");
}
}
tryCount ++;
if (tryCount > 29) break; // 1 Minute wait and exit
System.Threading.Thread.Sleep(2000); // 2 Second wait
}
Response.End();
%>
I was curious:
- is this waiting period affects other users?
- is this cause locks on IIS or pages ?
- is this usage effecting badly to CPU ?