c# - Create new thread, passing parameters -


I want to create a thread and then pass it to the parameter. But I do not know how.

  thread sitedownloader = new thread (new parameterized GetStart (GetHTML));   

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

  Stabilized string received HTML (string site url) {webclient webClient = new WebClient (); Try {string sitePrefix = siteURL.Substring (0, 7); If (sitePrefix! = "Http: //") {siteURL = "http: //" + siteURL; }} Hold {siteURL = "http: //" + siteURL; } Try {return webClient.DownloadString (siteURL); } Hold {return "404"; }}    

quote:

  public class work {Public Static Zero Main () {// To start a thread to use a shared thread process, // When you create, use // class name and method name. ParametritedTedDestate Representative C # / / Appropriate Representative Creation Estimates Syntax: // New ParameteratedThadeStart (Work.Dowwork) // Thread NewTrid = New Thread (Work. // Use the start of the start method in which the // parameter type is an object. You can create an object that contains several pieces of //, or you can pass any // reference type or value type. The following code passes / integer values ​​42. // newThread.Start (42); // To begin a thread by using an example method for thread // process, use the example variable and the method name when you create the // ParameteratedTeddTrepresenterC # infers // Proper representative construct syntax: // new parameterizedTedDrive (W.DoMoreWork) // work w = new work (); NewThread = New thread (WWW); // Pass the object with the data for the thread // newThread.Start ("reply."); } Public static Zero DoWork (object data) {Console.WriteLine ("Static Thread Process.Data = '{0}'", Data); } Public Zero DoMoreWork (Object Data) {Console.WriteLine ("Instant Thread Process.Data = '{0}'", Data); }}   

So you can see that you can create a method as a parameter with a object and this parameter should be set to start < / Code> can pass in the threads category

Comments