Async'd xml parsing - more to come on that
This commit is contained in:
parent
76f4b2adc9
commit
3dc824e1a4
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user