Hi,

I'm currently running multiple For Each loops which are time consuming loops. They started to cause issues so I added them to a backgroundworker, not only for the threading advantages but also the progress bar updating. However the below Split function is still causing the UI to freeze as it takes about 10 seconds to perform the split and the progress bar in the For Each loop that follows does not show the user that something is happening. Is there a way to stop the function from causing the freeze or making it update the progress bar?

Code:
lines = Split(My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName), vbNewLine)
For Each line In lines
    'More code
next
I know I can use a string as apposed to the lines array, update the backgroundworkers and loop the file line by line like this...

Code:
        processLength = File.ReadAllLines(OpenFileDialog1.FileName).Length
        For Each SplitLine As String In File.ReadAllLines(OpenFileDialog1.FileName)
            progressbarLabelText = "Processing data..."
            loopProcessCount += 1
            bwAMC.ReportProgress(((loopProcessCount / processLength) Mod 100) * 100)
            tempLine = tempLine & SplitLine & vbNewLine
        Next
But doing so means I would have to change all my code that uses the lines array. Something I hope to avoid.

Any suggestions would be greatly appreciated.

Regards,

S