I was wondering if there is a syntax for puting a timer on a local variable that is using XmlTextReader, instead of generating a whole new method for the XmlTextReader? What I want to do is read an xml file and display the findings, but put restrictions on how long the XmlTextReader can read that file.
Timer Class
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Dec 9, 2014, 5:54 AM EST
Although it only saves a line, there is a way to create and start the Stopwatch at the same time:
Stopwatch sw = Stopwatch.StartNew();
Otherwise, by altering the while condition as you've done, you could just use standard XmlTextReader code such as this example on MSDN:
http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.read(v=vs.110).aspx
Marc176 reputationPosted Dec 9, 2014, 5:03 AM EST
stopwatch sw = new Stopwatch();
sw.Start();
while(reader.Read() && sw.Elaped < TimeSpan.FormSeconds(5))
{
//read xml file
}