Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Threading/Process Peformance Issue

Status
Not open for further replies.

rw409168

Programmer
Joined
Jul 16, 2009
Messages
95
Location
GB
Greetings,

A form has some serious performance issues which begin when the form is launched.

From the menu which simply shows the form, it appears instantly but is somewhat "half drawn" resulting in a graphical glitch a delay of around 10 seconds occurs until normal service is restored.

Now I know this is due to me populating 4 combo box from the files below (See stats):-
towns 40,166 lines
cities 664 lines
counties 49 lines
Phonecodes 676 lines

I wait until the form is show before starting off 4 background workers to ease the load and allow the main GUI form thread to be active.

Form shown event

Code:
Me.BackgroundWorker1.RunWorkerAsync()
Me.BackgroundWorker2.RunWorkerAsync()
Me.BackgroundWorker3.RunWorkerAsync()
Me.BackgroundWorker4.RunWorkerAsync()

Each background work reads the files into a string array (see below)

BackgroundWorker1_DoWork

Code:
countyLookup = IO.File.ReadAllLines(My.Application.Info.DirectoryPath + "\lookupdata\counties.txt")

Finally when the background process is finished populate the combobox.

BackgroundWorker1_RunWorkerCompleted
Code:
Me.cboCounty.BeginUpdate()
Me.cboCounty.Items.AddRange(countyLookup)
Me.cboCounty.EndUpdate()

I was puzzled that the glitch appears even before the form is shown.

Does anyone have any ideas of how I can resolve the glitch?

The application backend is a MS database (*.accdb) and wondering if to make tables instead of reading the text files.

However tables containing just one field do seem pointless and note the address/phone code data is NOT RELATED.

Thanks
Rob

PS: Now I format my posts so they can be read easier :-)
 
Ignore my typo in the post title ;-)
 
Well I solved it using the streamreader, response time is much better.

I initially stayed away from teh streamreader as thought It was the old way as used by older versions of vb.

Code:
Dim sr As StreamReader = New StreamReader(My.Application.Info.DirectoryPath + "\lookupdata\towns.txt")

        Dim index As Integer = 0

        Do While (sr.Peek <> -1)
            ReDim Preserve townLookup(index)
            townLookup(index) = sr.ReadLine
            index += 1
        Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top