So i have set up a little project with a card reader and while the server is online it runs smooth. However once the server goes offline HttpResponse freezes and cant get out. i tought getting a reply code would help this but im all out of ideas.
Code as follows.
void Send2()
{
WebClient.GetFromWeb("http://" + IP + ":" + nPort + "/pool/user?ID=" + Card).ResponseReceived +=
new HttpRequest.ResponseHandler(Program_ResponseReceived);
}
void Program_ResponseReceived(HttpRequest sender, HttpResponse response)
{
if (response.StatusCode == "200")
{
answer = response.Text;
string[] nCard = answer.Split('/');
name.Text = nCard[0].Trim('\\', '"');
if (count == 0)
{
on.Text = "Signed: On";
count++;
}
else
{
on.Text = "Signed: Off";
count = 0;
}
time.Text = nCard[1].Trim('"');
Glide.MainWindow = logonW;
}
else
{
name.Text = "Http-Response: " + response.StatusCode;
Glide.MainWindow = logonW;
}
multicolorLed.BlinkOnce(GT.Color.Yellow);
Thread.Sleep(500);
multicolorLed.TurnGreen();
welcome.Text = "Welcome";
draw.Text = "Swipe card!";
Glide.MainWindow = mainW;
}