I was exploring how to use the BackgroundWorker with a very simple app to copy files from one folder to another. The code appears below.

When I click the Copy Folders button (ButtonCopyFoldersClick), it should start the copying process. Instead, as soon as I click the button, the labelCopyingMessage displays the text "Copying completed".

A quick check of the destination folder shows that contents of the source folder have not been copied to the destination folder.

If I take the line My.Computer.FileSystem.CopyDirectory("E:\SourceFolder", "D:\DestinationFolder", True) out of the DoWork sub, and place it in the ButtonCopyFolderClick sub, the files do get copied; so the syntax of the copy code is OK.

What am I missing here? There must be something I've overlooked, but what?

Code:
Imports System.Configuration
Imports System.Diagnostics
Imports System.Drawing
Imports System.IO
Imports System.IO.Ports
Imports System.Management
Imports System.Runtime.InteropServices

Public Partial Class MainForm
	Public Sub New()
		Me.InitializeComponent()
	End Sub
	
	Sub ButtonCopyFoldersClick(sender As Object, e As EventArgs)
		BackgroundWorkerCopyFolders.RunWorkerAsync()
	End Sub
	
	Sub BackgroundWorkerCopyFoldersDoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
		labelCopyingMessage.Text = "Copying folder to destination"
		My.Computer.FileSystem.CopyDirectory("E:\SourceFolder", "D:\DestinationFolder", True)
	End Sub
	
	Sub BackgroundWorkerCopyFoldersRunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs)
		labelCopyingMessage.Text = "Copying completed"
	End Sub
	
End Class