Click here to Skip to main content
15,880,725 members
Home / Discussions / C#
   

C#

 
Generalhttp remote file timestamp Pin
elraton15-Jan-04 9:29
elraton15-Jan-04 9:29 
GeneralRe: http remote file timestamp Pin
Heath Stewart15-Jan-04 9:55
protectorHeath Stewart15-Jan-04 9:55 
QuestionDoc / View i C# ? Pin
anderslundsgard15-Jan-04 7:25
anderslundsgard15-Jan-04 7:25 
AnswerRe: Doc / View i C# ? Pin
Heath Stewart15-Jan-04 9:53
protectorHeath Stewart15-Jan-04 9:53 
AnswerRe: Doc / View i C# ? Pin
Eric Gunnerson (msft)15-Jan-04 13:10
Eric Gunnerson (msft)15-Jan-04 13:10 
GeneralMetafile too small Pin
Torsch15-Jan-04 6:31
Torsch15-Jan-04 6:31 
GeneralParameters & Threading Pin
Anonymous15-Jan-04 4:56
Anonymous15-Jan-04 4:56 
GeneralRe: Parameters & Threading Pin
Heath Stewart15-Jan-04 6:49
protectorHeath Stewart15-Jan-04 6:49 
Async methods are a good way to start new threads and you don't have to worry about implementing in the callback - just use an empty method.

You could also use a ThreadPool, which uses the QueueUserWorkItem to thread a WaitCallback but that can also take an Object as a state variable that is passed to the WaitCallback - this could be anything from a single object to an array or list of arguments.

If you really don't want to use either of these, you should design a class that takes the parameters you want in the constructor or some properties and then uses an instance method on that class in the ThreadStart delegate. The delegate can then access all the fields in which those arguments are stored, like so:
public class MyThread
{
  private int i;
  private string s;
  public MyThread(int i, string s)
  {
    this.i = i;
    this.s = s;
    new Thread(new ThreadStart(this.Start)).Start();
  }
  private void Start()
  {
    Console.WriteLine("{0}, {1}", this.i, this.s);
  }
}


 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
Generalwindows service question Pin
Visuall15-Jan-04 4:55
Visuall15-Jan-04 4:55 
GeneralRe: windows service question Pin
Heath Stewart15-Jan-04 6:41
protectorHeath Stewart15-Jan-04 6:41 
GeneralADO.Net synchronization Pin
Judah Gabriel Himango15-Jan-04 4:49
sponsorJudah Gabriel Himango15-Jan-04 4:49 
GeneralRe: ADO.Net synchronization Pin
Not Active15-Jan-04 5:42
mentorNot Active15-Jan-04 5:42 
GeneralRe: ADO.Net synchronization Pin
Judah Gabriel Himango15-Jan-04 6:01
sponsorJudah Gabriel Himango15-Jan-04 6:01 
GeneralRe: ADO.Net synchronization Pin
Not Active15-Jan-04 6:28
mentorNot Active15-Jan-04 6:28 
GeneralRe: ADO.Net synchronization Pin
Judah Gabriel Himango15-Jan-04 8:34
sponsorJudah Gabriel Himango15-Jan-04 8:34 
GeneralRe: ADO.Net synchronization Pin
Heath Stewart15-Jan-04 6:31
protectorHeath Stewart15-Jan-04 6:31 
GeneralRe: ADO.Net synchronization Pin
Judah Gabriel Himango15-Jan-04 8:41
sponsorJudah Gabriel Himango15-Jan-04 8:41 
GeneralRe: ADO.Net synchronization Pin
Heath Stewart15-Jan-04 9:27
protectorHeath Stewart15-Jan-04 9:27 
GeneralRe: ADO.Net synchronization Pin
Judah Gabriel Himango15-Jan-04 8:47
sponsorJudah Gabriel Himango15-Jan-04 8:47 
GeneralRe: ADO.Net synchronization Pin
Heath Stewart15-Jan-04 9:31
protectorHeath Stewart15-Jan-04 9:31 
GeneralRe: ADO.Net synchronization Pin
Mazdak15-Jan-04 5:53
Mazdak15-Jan-04 5:53 
GeneralRe: ADO.Net synchronization Pin
Judah Gabriel Himango15-Jan-04 6:06
sponsorJudah Gabriel Himango15-Jan-04 6:06 
GeneralRe: ADO.Net synchronization Pin
Mazdak15-Jan-04 6:28
Mazdak15-Jan-04 6:28 
GeneralCryptGenKey -use of ALG_ID type Pin
Member 51467215-Jan-04 4:39
Member 51467215-Jan-04 4:39 
GeneralRe: CryptGenKey -use of ALG_ID type Pin
Heath Stewart15-Jan-04 6:28
protectorHeath Stewart15-Jan-04 6:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.