异步XML阅读Windows Phone 8

时间:2013-05-10 08:12:19

标签: c# xml asynchronous windows-phone-8 async-await

我目前正在使用XDocument阅读xml文件。 正在使用带参数的方法读取XML,目前看起来像这样:

private MyXmlFiles_Row GetXmlData(int Year, TAN ANAG, TVerdTyp VerdTyp) {

    XDocument loadedCustomData = XDocument.Load("XML\\MyXmlFiles.xml");
    XName SucheName = "MyXmlFiles";
        IEnumerable<MyXmlFiles_Row> filteredData = from query in loadedCustomData.Descendants(SucheName)
        where query.Element("Year").Value == Year.ToString().Trim() && query.Element("TAN").Value == ANAG.ToString().Trim() && query.Element("TVerdTyp").Value == VerdTyp.ToString().Trim()
        select new BeitrProzent_Row(    
                    Convert.ToDouble(query.Element("One").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Two").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Three").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Four").Value, CultureInfo.InvariantCulture),
                    Convert.ToDouble(query.Element("Five").Value, CultureInfo.InvariantCulture));

    return filteredData.ElementAt(0);
}

如何加载xml文件异步(或使用BackgroundWorker)?

0 个答案:

没有答案