I am writing my first VB.Net program and have come across an
interesting problem. My department generates large volumes of
documents. By law we are required to keep the documents for a specific
period of time based on several factors.
The IT department has been asked to develop a program to assist in
archiving the older documents. We have a stored procedure that returns
the docket numbers to the cases that may have documents which are
eligible to be archived. Based on the docket number the path to the
directory where the documents are stored can be calculated.
I developed several classes that takes the list of docket numbers and
checks the file sizes of each document and divides the directories and
documents into CD volumes. It first creates a list of CD volumes and
which directories and transcripts are in each volume. It then
populates a treeview with the information.
As the program does its job it uses a progressbar to let the user know
how far along it is and after fully populating a CD volume node with
the associated directories and transcripts in those directories is
refreshes. The effect is that the user sees each CD node pop into view
when it is fully populated.
The problem is, however, that sometimes the progressbar and the
treeview stop refreshing. This gives the appearance that the program
has hung. But in the end the treeview and progress bar suddenly
refresh and all of the CD volumes will pop into view. There is no way
for the code that increments the progressbar or the code that updates
the treeview can be skipped and have the nodes still be populated. Can
anyone tell me what may be going on? Below is the sub where the nodes
are being poplulated:
Private Sub DisplayVolumes()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim v As Volume
Dim d As Directory
Dim t As Transcript
InitImageList()
vL = aM.GetVolumes()
For i = 1 To vL.Count
v = vL(i)
ProgressBar1.Maximum = v.Count
StatusBar1.Text = "Populating Nodes for CD-" & i
VolumeTreeView.Nodes.Add(New TreeNode(v.Name, 1, 2))
Dim n As TreeNode = VolumeTreeView.Nodes(i - 1)
For j = 1 To v.Count
ProgressBar1.Value = j
d = v.GetDirectory(j)
n.Nodes.Add(New TreeNode(d.Name, 3, 4))
Dim m As TreeNode = n.Nodes(j - 1)
For k = 1 To d.Count
t = d.GetTranscript(k)
m.Nodes.Add(New TreeNode(t.Name, 5, 5))
Next
Next
VolumeTreeView.Refresh()
Next
End Sub