How to really develop a multithreading application ?

Posted on 2004-11-10
Last Modified: 2010-04-23
I'm trying to write a simple URL downloader.

But I want a real mutithreading, For example I have 100 website and I want to download them 20 by 20. threadcount = 20

I want to use threadpool, but I don't know how. I couldn't find any real solution in anywhere about this.

My save class is
Class savePage
    Public url, filename As String

    Public Sub save()
        Dim wc As New WebClient
        wc.DownloadFile(url, filename)
    End Sub

End Class

Now I want to save 100 URL multithreaded (threadpool).

Question by:herterx
    LVL 2

    Accepted Solution

    Imports System
    Imports System.Threading

    Public Class Example
        Public Shared Sub Main()
            ' Queue the task.
            ThreadPool.QueueUserWorkItem(AddressOf ThreadProc)
            Console.WriteLine("Main thread does some work, then sleeps.")
            ' If you comment out the Sleep, the main thread exits before
            ' the thread pool task runs.  The thread pool uses background
            ' threads, which do not keep the application running.  (This
            ' is a simple example of a race condition.)

            Console.WriteLine("Main thread exits.")
        End Sub

        ' This thread procedure performs the task.
        Shared Sub ThreadProc(stateInfo As Object)
            ' No state object was passed to QueueUserWorkItem, so
            ' stateInfo is null.
            Console.WriteLine("Hello from the thread pool.")
        End Sub
    End Class

    LVL 2

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now