I have written a code like following:
newFilteredList.AsParallel().WithDegreeOfParallelism(60).ForAll(qqmethod =>
{
var xdocic = new XmlDocument();
xdocic.LoadXml(SendRequest(null, null, qqmethod.ItemID, true, TotalDaysSinceLastUpdate.ToString(), null));
int TotalPages = 0;
if (xdocic.GetElementsByTagName("TotalNumberOfPages").Item(0) != null)
{
TotalPages = Convert.ToInt32(xdocic.GetElementsByTagName("TotalNumberOfPages").Item(0).InnerText);
}
if (TotalPages > 1)
{
Parallel.For(1, TotalPages + 1, i =>
{
Products.Add(//Add something here);
});
}
else
{
Products.Add(//add omething here);
}
});
The line where I get error is the following:
var xdocic = new XmlDocument();
xdocic.LoadXml(SendRequest(null, null, qqmethod.ItemID, true, TotalDaysSinceLastUpdate.ToString(), null));
And it says that some of these variables is either null or I'm missing something here.
On a side note, TotalDaysSinceLastUpdate variable is declared just as a regular integer variable, is that why I'm getting this error?
What could it be guys?