littlebigman
Well-known member
- Joined
- Jan 5, 2010
- Messages
- 75
- Programming Experience
- Beginner
Hello
I was looking for a solution to run a lengthy job (looking for files on the fixed drives) withouth freezing the UI, and saw that using a BackGroundWorker control is the recommended solution.
Problem is, I don't see its ProgressChange event being triggered:
Does someone know what it takes to have this event to be triggered every so often?
Thank you.
I was looking for a solution to run a lengthy job (looking for files on the fixed drives) withouth freezing the UI, and saw that using a BackGroundWorker control is the recommended solution.
Problem is, I don't see its ProgressChange event being triggered:
VB.NET:
Imports System.IO
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
bgrLongProcess.WorkerReportsProgress = True
bgrLongProcess.WorkerSupportsCancellation = True
bgrLongProcess.RunWorkerAsync()
End Sub
Private Sub bgrLongProcess_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgrLongProcess.ProgressChanged
'This event never called?
Me.Text = DateTime.Now.ToString
DataGridView1.Refresh()
End Sub
Private Sub bgrLongProcess_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgrLongProcess.RunWorkerCompleted
Button1.Enabled = True
End Sub
Private Sub bgrLongProcess_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgrLongProcess.DoWork
'Do lengthy stuff here
For Each drive In DriveInfo.GetDrives()
If drive.DriveType = DriveType.Fixed Then
'To avoid "Access to the path 'C:\System Volume Information' is denied." msg
Try
filelist = My.Computer.FileSystem.GetFiles(drive.ToString, FileIO.SearchOption.SearchAllSubDirectories, "Edit.*")
For Each filepath In filelist
'do stuff
Next filepath
Catch Ex As UnauthorizedAccessException
'Ignore protected directory, and move on
Continue For
End Try
End If
Next drive
End Sub
End Class
Does someone know what it takes to have this event to be triggered every so often?
Thank you.