public RequestsChecker(TrayApplicationContext appContext) { Thread requestsThread = new Thread(() => { RunRequestsCheck(appContext); }); requestsThread.Start(); }
private static void RunRequestsCheck(TrayApplicationContext appContext) { //WebRequest.DownloadWebPage(); //WebRequestResponse.PostMeToSamplePage(); //WebRequestResponse.TestMethod(); //var request = WebRequestResponse.CreateWebRequestFromString("http://google.cz"); //HttpWebResponse response = WebRequestResponse.GetNetResponseFromWebRequestAndDoNothingIfItFails(request); //string responseText = WebRequestResponse.GetStringFromWebResponse(response); string sd = "https://burstsms-burst-sms.p.mashape.com/send-sms.json/?message=ghello&to=721083504"; WebCommunication.DownloadWebPage(sd); //load value from config int previousTotalCountOfRequests = (int)Properties.Settings.Default["lastCountOfRequests"]; //int previousTotalCountOfRequests = 0; int numberOfRequests = 0; while (true) { int currentTotalCountOfRequests = WebRequestResponse.ProcessRequestAndReturnDeserializedResult<int>(CONCRETEREQUEST.CHECK); if (currentTotalCountOfRequests != previousTotalCountOfRequests) { numberOfRequests += currentTotalCountOfRequests - previousTotalCountOfRequests; //save new number Properties.Settings.Default["lastCountOfRequests"] = numberOfRequests; Properties.Settings.Default.Save(); // string requestAddedMessage = "Request added, now theres " + numberOfRequests + " requests"; appContext.OnRequestAddedShowNotification(requestAddedMessage); } previousTotalCountOfRequests = currentTotalCountOfRequests; Thread.Sleep(60000); } }