Async'd xml parsing - more to come on that

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-19 20:15:03 -04:00
parent 76f4b2adc9
commit 3dc824e1a4

View File

@ -17,18 +17,15 @@ namespace MediaBrowser.Controller.Xml
/// <summary>
/// Fetches metadata for an item from one xml file
/// </summary>
public Task Fetch(T item, string metadataFile)
{
// Wrapping this for now until I have a chance to async the whole process
return Task.Run(() =>
public async Task Fetch(T item, string metadataFile)
{
// Use XmlReader for best performance
using (XmlReader reader = XmlReader.Create(metadataFile))
using (XmlReader reader = XmlReader.Create(metadataFile, new XmlReaderSettings() { Async = true }))
{
reader.MoveToContent();
await reader.MoveToContentAsync();
// Loop through each element
while (reader.Read())
while (await reader.ReadAsync())
{
if (reader.NodeType == XmlNodeType.Element)
{
@ -47,7 +44,6 @@ namespace MediaBrowser.Controller.Xml
{
item.DateModified = File.GetLastWriteTime(metadataFile);
}
});
}
/// <summary>