

InterviewSolution
1. |
Solve : creating threads in C#? |
Answer» Can someone please break down a simple statement for a relative newbie? If it's all the same to you, I'll set my own career path, thank you very much. heh, on the other hand, C# would be a forward thinking investment... (assuming that .NET manages to take off, which wouldn't be an unfair assumption). In either case... that wasn't relevant... my response I mean... to your question My apologies. Code: [Select]Thread firstThread = new Thread (new ThreadStart (Method1)); As I'm sure your aware, unlike C, C++ and C# deal with Objects. Quite a departure from the Structured Programming of C and Pascal. This line, as you know, creates a new thread. the "new" keyword is used to create a new thread. However, in order to create a new thread, you must pass in a "ThreadStart" object to the Thread's constructor, a special function that is called when you create an instance of the class. In this case, a new ThreadStart Object is created right in the parameter list to the Thread Constructor. But oh Dear! the ThreadStart() Constructor also needs a bit of information- the METHOD that will comprise this thread. In your example, this is the function "method1". If I am CORRECT, this code would create the thread- but would not START it, the firstThread object can of course be told to start,suspend, terminate, etc via it's methods. |
|