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

  • Home
  • SEARCH
  • 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 4122928
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:32:44+00:00 2026-05-20T23:32:44+00:00

I want to create a thread and then pass parameters to it. But I

  • 0

I want to create a thread and then pass parameters to it. But I don’t know how.

Thread siteDownloader = new Thread(new ParameterizedThreadStart(GetHTML));

This is function that I want to launch as new thread.

static string GetHTML(string siteURL)
{
    WebClient webClient = new WebClient();

    try
    {
        string sitePrefix = siteURL.Substring(0, 7);
        if (sitePrefix != "http://")
        {
            siteURL = "http://" + siteURL;
        }
    }
    catch
    {
        siteURL = "http://" + siteURL;
    }

    try
    {
        return webClient.DownloadString(siteURL);
    }
    catch
    {
        return "404";
    }
}
  • 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-05-20T23:32:45+00:00Added an answer on May 20, 2026 at 11:32 pm

    Citing the msdn:

    public class Work
    {
        public static void Main()
        {
            // To start a thread using a shared thread procedure, use
            // the class name and method name when you create the 
            // ParameterizedThreadStart delegate. C# infers the 
            // appropriate delegate creation syntax:
            //    new ParameterizedThreadStart(Work.DoWork)
            //
            Thread newThread = new Thread(Work.DoWork);
    
            // Use the overload of the Start method that has a
            // parameter of type Object. You can create an object that
            // contains several pieces of data, or you can pass any 
            // reference type or value type. The following code passes
            // the integer value 42.
            //
            newThread.Start(42);
    
            // To start a thread using an instance method for the thread 
            // procedure, use the instance variable and method name when 
            // you create the ParameterizedThreadStart delegate. C# infers 
            // the appropriate delegate creation syntax:
            //    new ParameterizedThreadStart(w.DoMoreWork)
            //
            Work w = new Work();
            newThread = new Thread(w.DoMoreWork);
    
            // Pass an object containing data for the thread.
            //
            newThread.Start("The answer.");
        }
    
        public static void DoWork(object data)
        {
            Console.WriteLine("Static thread procedure. Data='{0}'",
                data);
        }
    
        public void DoMoreWork(object data)
        {
            Console.WriteLine("Instance thread procedure. Data='{0}'",
                data);
        }
    }
    

    so as you can see you create a method with an object as a parameter and pass this parameter to the Start method of the Thread class

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

Sidebar

Related Questions

I have a multithreaded program where I create a generator function and then pass
I want to create one thread for each row of my 2D array. Then
I create a java.util.concurrent.locks.ReentrantReadWriteLock using new java.util.concurrent.locks.ReentrantReadWriteLock().readLock() and then I pass to a method
I want to create a Thread safe JSP page. It is possible in Servlet
I want to create a background thread that's owned by an object. When that
I want to create a separate thread that runs its own window. Frankly, the
I want to create a worker thread that isn't the main thread so I
I want to create dynamic number of thread which is depends on the database
I want to pass an exception from current thread (that thread isn't main thread)to
I have tried to search before i made a decision to create this new

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.