Have a look at this:
vb.net Code:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'' move this to the start of your DoWork event procedure
Dim worker As System.ComponentModel.BackgroundWorker = DirectCast(sender, System.ComponentModel.BackgroundWorker)
'' your other code
Do While rdrfile.Peek <> -1
'' your other code
If worker.CancellationPending Then Exit Do
Loop
'' your other code
For Each Str As String In FileLines
'' your other code
If worker.CancellationPending Then Exit For
Next
For Each filtereditem As String In Columns
'' your other code
If worker.CancellationPending Then Exit For
Next
'' your other code
For Each item In Lines
'' your other code
If worker.CancellationPending Then Exit For
Next
'' your other code
'' just before End Sub
If worker.CancellationPending Then e.Cancel = True
End Sub