Skip to content

Commit

Permalink
Added Timeout to Menu fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
Islam Wahdan committed Dec 11, 2015
1 parent b1bfe67 commit 84b877a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ACID/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Drawing;
using System.Threading;
using System.IO.Ports;
using System.Net;

namespace ACID
{
Expand Down Expand Up @@ -114,7 +115,27 @@ public Engine(String UserID, String Pass): base(UserID, Pass)
/*Get Menu Data*/
try
{
xmlFile.Load(@"https://storage-download.googleapis.com/menudata/MenuItems_Final.xml");
// Create a request for the URL.
WebRequest request = WebRequest.Create("https://storage-download.googleapis.com/menudata/MenuItems_Final.xml");
request.Timeout = 60000;
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();

// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();

xmlFile.LoadXml(responseFromServer);
xmlFile.Save(@"./Backup/MenuItems.xml");
PBar.Auth.Invoke(PBar.myDelegate);
ProgressTherad.Abort();
Expand Down

0 comments on commit 84b877a

Please sign in to comment.