Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8901399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:20:41+00:00 2026-06-15T01:20:41+00:00

I need a little (or big) help with my form: I need to use

  • 0

I need a little (or big) help with my form: I need to use everything inside the “Organize function” region in a separate thread.

I press a button in my form’s “Start button” region to call the first sub of the “Organize function” subs; the first sub calls the second sub and the second sub calls the third sub.

I tried adding the third sub into a separate thread by myself and then using the second sub to pass the argument to the thread but all I’ve done is wrong.

Can someone please help me do this?

PS: I’ve deleted the non-important parts in this form to let you check better.

Thank you for reading.

Public Class Form1


#Region "Declarations"

        ' MediaInfo
        Dim MI As MediaInfo

        ' Thread
        Dim paused As Boolean = False

        ' Others
        Dim NameOfDirectory As String = Nothing
        Dim aFile As FileInfo

#End Region



    'thread
    Dim t As New Thread(AddressOf ThreadProc)

    Public Sub ThreadProc()
        ' Aqui debería ir  todo el sub de "organize function", bueno... son 3 subs!
        If paused = True Then MsgBox("THREAD PAUSADO")
    End Sub



#Region "Properties"
...
#End Region

#Region "Load / Close"
...
#End Region

#Region "Get Total files Function"
...
#End Region

#Region "Option checkboxes"
...
#End Region

#Region "Folder buttons"
...
#End Region

#Region "Append text function"
...
#End Region





#Region "Action buttons"

   ' pause button
    Private Sub pause_button_Click(sender As Object, e As EventArgs) Handles pause_button.Click
        paused = True
    End Sub

    ' start button
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles start_button.Click

              t.Start()

                    ' Organization process
                    NameOfDirectory = userSelectedFolderPath
                    MediaInfo(NameOfDirectory)

        End Sub

#End region





#Region "Organize function"

        Public Sub MediaInfo(Directory)
            Dim MyDirectory As DirectoryInfo
            MyDirectory = New DirectoryInfo(NameOfDirectory)
            MediaInfoWorkWithDirectory(MyDirectory)
        End Sub

        Public Sub MediaInfoWorkWithDirectory(ByVal aDir As DirectoryInfo)
            Dim nextDir As DirectoryInfo
            MediaInfoWorkWithFilesInDir(aDir)
            For Each nextDir In aDir.GetDirectories
                Using writer As StreamWriter = New StreamWriter(aDir.FullName & "\" & nextDir.Name & "\" & nextDir.Name & ".m3u", False, System.Text.Encoding.UTF8)
                    'overwrite existing playlist
                End Using
                MediaInfoWorkWithDirectory(nextDir)
            Next
        End Sub

        Public Sub MediaInfoWorkWithFilesInDir(ByVal aDir As DirectoryInfo)

            Dim aFile As FileInfo





            For Each aFile In aDir.GetFiles()

               ' hacer cosas con aFile ...

            Next

        End Sub

#End Region



End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:20:42+00:00Added an answer on June 15, 2026 at 1:20 am

    There is a Windows Forms component called BackgroundWorker that is designed specifically to offload long-running tasks from the UI thread to a background thread, leaving your form nice and responsive.

    The BackgroundWorker component has an event called DoWork that is used to execute code on a separate thread. Drag the BackgroundWorker component onto your form and then do something like this:

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles start_button.Click
        NameOfDirectory = userSelectedFolderPath
        backgroundWorker1.RunWorkerAsync(NameOfDirectory)
    End Sub
    
    Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim directoryName as string = e.Argument
    
        MediaInfo(directoryName)
    End Sub
    

    A couple of links that might be useful are the MSDN BackgroundWorker page and an example on Code Project.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need a little help with my jquery here I want all my button with
I need a little help about the zoomify. I want to display big images,
I need little help for url rewriting in wordpress. basically what i need: mydomain.com/mysomewordpresspost
I would need little help here. I'm trying to get the git respository from
Need a little help with a SQL / ActiveRecord query. Let's say I have
I need a little help with an if statement in php. I'm trying to
I need a little help setting up a HTTP Post in C#. I appreciate
I need a little help getting this script doing what I want it to.
I need a little help here please.What am trying to do is pull all
I need a little help getting a tar file to download from a website.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.