Results 1 to 7 of 7

Thread: [Resolved][2008]Question about multithreading

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    74

    [Resolved][2008]Question about multithreading

    Am I doing this correctly? So always if I use this multi thing I put start & join?

    Code:
        Dim MyThread1 As New System.Threading.Thread(AddressOf getlinks1)
        Dim MyThread2 As New System.Threading.Thread(AddressOf getlinks2)
    
        Sub main()
            MyThread1 .Start()
            MyThread1 .Join()
            MyThread2 .Start()
            MyThread2 .Join()
        End Sub
    
        Sub getlinks1()
            Dim ProcID As Integer
            ProcID = Shell("getlinkcollection.exe")
        End Sub
    
        Sub getlinks2()
            Dim ProcID As Integer
            ProcID = Shell("getlinkcollection.exe")
        End Sub
    Last edited by goldenix; Apr 15th, 2008 at 05:49 PM.

    M.V.B. 2008 Express Edition

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2008]Question about multithreading

    Join will block the calling thread until the getlinks1/getlinks2 thread terminates. If you dont specifically want this to happen, then dont call Join.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    74

    Re: [2008]Question about multithreading

    Quote Originally Posted by Atheist
    Join will block the calling thread until the getlinks1/getlinks2 thread terminates. If you dont specifically want this to happen, then dont call Join.
    So basically it put in a queue? therefore calling join is very smart idea. K thanx.

    M.V.B. 2008 Express Edition

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [Resolved][2008]Question about multithreading

    In this simple case, I dont see a reason to even use threads if you're planning on calling Join.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    74

    Re: [Resolved][2008]Question about multithreading

    Quote Originally Posted by Atheist
    In this simple case, I dont see a reason to even use threads if you're planning on calling Join.
    This was simply an example. What im after is to make the code in a way so I can start a thread in my GUI(for example scanning my C drive & updating progressbar in the gui) & then i can do other stuff within the GUI (like pressing buttons etc.) without my GUI freezing to death & i need to wait until its finished doing that earlier thread.

    M.V.B. 2008 Express Edition

  6. #6
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: [Resolved][2008]Question about multithreading

    The BackGroundWorker class or component would be much easier to use:
    http://msdn2.microsoft.com/en-us/lib...undworker.aspx

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    74

    Re: [Resolved][2008]Question about multithreading

    k i just finished this Walkthrough: Running an Operation in the Background
    & I must say I understood practically nothing & if I compare it to my sample code I would say my sample is much easier to use that this background worker. & not only easier, but also the code will be a lot smaller.

    M.V.B. 2008 Express Edition

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width