Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27121

que actions for background worker

$
0
0
i have a a list of files that i get from a drop panel

i.e
Code:


theFiles = CType(e.Data.GetData("FileDrop", True), String())

later on i need to run throught each of these files and perform a copy of them using a backgroundworker based on there file extension to filter if they are files or folders if they are files i start the files BGW if they are folders i start the folder BGW.

this is what i tried

Code:

    Private Sub Run_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Run_btn.Click

        ''Get Destination if HDD



        If Not Directory.Exists(My.Computer.FileSystem.CurrentDirectory & "/Backups/" & Prifle_NameTextBox.Text) Then

            Directory.CreateDirectory(My.Computer.FileSystem.CurrentDirectory & "/Backups/" & Prifle_NameTextBox.Text)
            di = New DirectoryInfo(My.Computer.FileSystem.CurrentDirectory & "/Backups/" & Prifle_NameTextBox.Text)
            Dest = My.Computer.FileSystem.CurrentDirectory & "/Backups/" & Prifle_NameTextBox.Text & "/"

        Else

            Dest = My.Computer.FileSystem.CurrentDirectory & "/Backups/" & Prifle_NameTextBox.Text & "/"

        End If

        Dim File_Type As String

        For Each theFile As String In theFiles

            File_Type = Path.GetExtension(theFile)

            If TextFiles.Contains(File_Type) Or AudioFiles.Contains(File_Type) Or VideoFiles.Contains(File_Type) Or VectorFiles.Contains(File_Type) Or CompressesFiles.Contains(File_Type) Or DiskImageFiles.Contains(File_Type) Or DeveloperFiles.Contains(File_Type) Or MiscFiles.Contains(File_Type) Then


                Me.Copy_File_BGW.RunWorkerAsync()

            Else

                Me.Copy_Folder_BGW.RunWorkerAsync()

            End If

        Next

    End Sub

However as i expected this works great for the first file but then i get an error about how the background worker is already in use.

So i guess i need help in trying to work out how to add these files to a que of some sort and run them in a background worker 1 at a time.

Viewing all articles
Browse latest Browse all 27121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>