我有一个WPF表单,其中在底部添加了一个进度条。该程序的目的是读取xml,然后进行更新以进行访问。在整个过程中,我希望进度条能够更新,因为XML很大。
我正在使用XMLReader(请参见下面的代码)。单击按钮时触发此代码。有人可以帮助读取XML时更新进度条(%)吗?
我还希望将数据复制到Access时更新第二个进度条,为此,我还有另一个从Button2触发的功能。
Dim ADCECounter As Integer = 0
Dim settings As New XmlReaderSettings
settings.DtdProcessing = DtdProcessing.Ignore
Dim xReader As XmlReader = XmlReader.Create(xml_txtbox_2G.Text, settings)
Dim ns As XNamespace = XNamespace.Get("raml20.xsd")
Dim ADCE_DT As New DataTable
ADCE_DT = DataTables2G.Tables2G.ADCE_DT
Dim start As DateTime = DateTime.Now
Dim elapstedtime As Double
While (Not xReader.EOF)
If xReader.Name <> "managedObject" Then
xReader.ReadToFollowing("managedObject")
End If
If Not xReader.EOF Then
Dim managedObject As XElement = XElement.ReadFrom(xReader)
If CType(managedObject.Attribute("class"), String) = "ADCE" Then
Call XMLParse2G.XMLParse.ADCE(ADCE_DT, managedObject, ns)
ADCECounter = ADCECounter + 1
End If
End If
End While
进度栏在MainWindow.xaml(WPF)中声明。
<ProgressBar x:Name="ProgressBar1" Grid.ColumnSpan="3" Height="20" Margin="2,2,2,2" Padding="2" />