Hi, Im trying to build an app that retrieves real-time fx quotes.
Im getting an exception "cannot access a disposed object" when I try to make a 2nd call to GetResponse() even though I am disposing off it through using statements (I've tried to call Close() manually; this did not solve problem).
Code:
static void Main(string[] args)
{
string sessionID = "xxxxxx";
HttpWebRequest rateRequest = HttpWebRequest.Create(string.Format(@"http://webrates.truefx.com/rates/connect.html?id={0}", sessionID)) as HttpWebRequest;
HttpWebResponse rateResponse;
while (true)
{
using (rateResponse = rateRequest.GetResponse() as HttpWebResponse)
{
if (rateResponse != null)
{
using (StreamReader rateReader = new StreamReader(rateResponse.GetResponseStream()) )
{
Console.WriteLine(rateReader.ReadToEnd());
}
}
}
}
}
Would really appreciate some help!