R
Rob W
Greetings,
There is a small delay of around 4-5 seconds where the form freezes before
all form elements are displayed as its run the background process that
appears to halt the UI thread (code below)
Any ideas of how to process the reading and processing of the text files in
a manner which will least be noticed by the user?
Thanks Rob
Private Sub frmAddMember_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e
As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
titleLookup = New String() {" ", "Dr", "Prof", "Miss", "Ms", "Mr", "Mrs"}
townLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\towns.txt", System.Text.Encoding.Default)
cityLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\cities.txt", System.Text.Encoding.Default)
countyLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\counties.txt", System.Text.Encoding.Default)
STDcodeLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\phonecodes.txt", System.Text.Encoding.Default)
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object,
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
BackgroundWorker1.RunWorkerCompleted
'Populate address comboboxes from THREE textfiles in the startup path dir
'No need to sort items as already sotred in text file
'Note: The address data is NOT relational (maybe future edition)
Me.cboTitle.Items.AddRange(titleLookup)
Me.cboTown.Items.AddRange(townLookup)
Me.cboCity.Items.AddRange(cityLookup)
Me.cboCounty.Items.AddRange(countyLookup)
Me.cboSTDCode.Items.AddRange(STDcodeLookup)
End Sub
There is a small delay of around 4-5 seconds where the form freezes before
all form elements are displayed as its run the background process that
appears to halt the UI thread (code below)
Any ideas of how to process the reading and processing of the text files in
a manner which will least be noticed by the user?
Thanks Rob
Private Sub frmAddMember_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e
As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
titleLookup = New String() {" ", "Dr", "Prof", "Miss", "Ms", "Mr", "Mrs"}
townLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\towns.txt", System.Text.Encoding.Default)
cityLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\cities.txt", System.Text.Encoding.Default)
countyLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\counties.txt", System.Text.Encoding.Default)
STDcodeLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath +
"\lookupdata\phonecodes.txt", System.Text.Encoding.Default)
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object,
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
BackgroundWorker1.RunWorkerCompleted
'Populate address comboboxes from THREE textfiles in the startup path dir
'No need to sort items as already sotred in text file
'Note: The address data is NOT relational (maybe future edition)
Me.cboTitle.Items.AddRange(titleLookup)
Me.cboTown.Items.AddRange(townLookup)
Me.cboCity.Items.AddRange(cityLookup)
Me.cboCounty.Items.AddRange(countyLookup)
Me.cboSTDCode.Items.AddRange(STDcodeLookup)
End Sub