0
我使wpf應用程序運行良好。但是,無論何時我的xml的大小很大,它的運行速度非常慢,我們每次從xml獲取數據時,代碼如下 是任何機構建議我就是因爲這樣,也可以是其他的問題如何優化wpf應用程序的性能
我如何改革這個 感謝 shashank`
DataSet xmlData = new DataSet();
XmlTextReader reader = null;
try
{
if (File.Exists(CommonUtils.xmlPath))
{
//convert XmlDocument to XmlTextReader
reader = new XmlTextReader(new StringReader(CommonUtils.DecryptXML().OuterXml));
//get the xml data
xmlData.ReadXml(reader);
reader.Close();
//get category rows from
DataRow[] eventRows = xmlData.Tables["M_EVENT"].Select(" ROW_STATUS=1");
if (eventRows.Length > 0)
{
//create a datatable for event
DataTable dtEvent = xmlData.Tables["M_EVENT"].Clone();
//add a default row to the event table
DataRow dr = dtEvent.NewRow();
dr[0] = "-1";
dr[1] = "--Select Event--";
dr[2] = "1";
dtEvent.Rows.InsertAt(dr, 0);
foreach (DataRow row in eventRows)
{
DataRow drEvent = dtEvent.NewRow();
drEvent["PK_EVENT_ID"] = row["PK_EVENT_ID"];
drEvent["EVENT_NAME"] = row["EVENT_NAME"];
drEvent["EVENT_TYPE"] = row["EVENT_TYPE"];
dtEvent.Rows.Add(drEvent);
}
//bind the category drop down
cmbEvent.DataContext = dtEvent.DefaultView;
cmbEvent.SelectedValuePath = "PK_EVENT_ID";
cmbEvent.DisplayMemberPath = "EVENT_NAME";
cmbEvent.SelectedIndex = 0;
}
}
else
{
Lblgetevent.Visibility = Visibility.Visible;
}
}`