Click here to Skip to main content
15,906,558 members
Home / Discussions / C#
   

C#

 
GeneralRe: Simple MultiThread question Pin
PozzaVecia28-Jan-12 1:21
PozzaVecia28-Jan-12 1:21 
GeneralRe: Simple MultiThread question Pin
OriginalGriff28-Jan-12 2:41
mveOriginalGriff28-Jan-12 2:41 
AnswerRe: Simple MultiThread question Pin
Luc Pattyn27-Jan-12 22:22
sitebuilderLuc Pattyn27-Jan-12 22:22 
GeneralRe: Simple MultiThread question Pin
PozzaVecia28-Jan-12 1:56
PozzaVecia28-Jan-12 1:56 
AnswerRe: Simple MultiThread question Pin
Luc Pattyn28-Jan-12 2:29
sitebuilderLuc Pattyn28-Jan-12 2:29 
GeneralRe: Simple MultiThread question Pin
harold aptroot28-Jan-12 2:24
harold aptroot28-Jan-12 2:24 
AnswerRe: Simple MultiThread question Pin
Luc Pattyn28-Jan-12 2:50
sitebuilderLuc Pattyn28-Jan-12 2:50 
AnswerRe: Simple MultiThread question Pin
BobJanova28-Jan-12 6:45
BobJanova28-Jan-12 6:45 
If you're using .Net 4, look at the Task Parallel Library. It is designed specifically for running parallel tasks which is what you appear to be trying to do here.

In the old days I would create a thread (now I'd name it task, but this comes from the Java model where I first learnt multithreading) class that stored the state of a particular operation:

class MyTask {
 double a,b;
 Thread t;
 ManualResetEvent wh;

 ManualResetEvent WaitHandle { get { return wh; } }
 public Thread Thread { get { return t; } }

 MyTask(double a, double b) {
  this.a = a; this.b = b; 
  t = new Thread(new ThreadStart(Run));
  wh = new ManualResetEvent();
 }

 private void Run(){
  // do whatever with a and b
  wh.Signal();
 }
}


... and call it like
Thread thread = new MyTask(11, 15).Thread;
thread.Start();

or, if you care about the wait handle:
MyTask task = new MyTask(11, 15);
task.Thread.Start();
task.WaitHandle.WaitOne();


But I do stress that the TPL will do all this stuff fairly nicely without requiring you to write code.
GeneralRe: Simple MultiThread question Pin
PozzaVecia28-Jan-12 9:50
PozzaVecia28-Jan-12 9:50 
QuestionConverting MySqlDateTime Pin
Ian_urquhart27-Jan-12 4:50
Ian_urquhart27-Jan-12 4:50 
AnswerRe: Converting MySqlDateTime Pin
Bernhard Hiller27-Jan-12 5:01
Bernhard Hiller27-Jan-12 5:01 
GeneralRe: Converting MySqlDateTime Pin
Ian_urquhart27-Jan-12 5:27
Ian_urquhart27-Jan-12 5:27 
AnswerRe: Converting MySqlDateTime Pin
PIEBALDconsult27-Jan-12 5:08
mvePIEBALDconsult27-Jan-12 5:08 
GeneralRe: Converting MySqlDateTime Pin
Ian_urquhart27-Jan-12 5:31
Ian_urquhart27-Jan-12 5:31 
GeneralRe: Converting MySqlDateTime Pin
Richard Andrew x6427-Jan-12 16:43
professionalRichard Andrew x6427-Jan-12 16:43 
GeneralRe: Converting MySqlDateTime Pin
PIEBALDconsult28-Jan-12 4:03
mvePIEBALDconsult28-Jan-12 4:03 
GeneralRe: Converting MySqlDateTime Pin
jschell28-Jan-12 4:39
jschell28-Jan-12 4:39 
GeneralRe: Converting MySqlDateTime Pin
PIEBALDconsult28-Jan-12 12:05
mvePIEBALDconsult28-Jan-12 12:05 
GeneralRe: Converting MySqlDateTime Pin
jschell28-Jan-12 13:54
jschell28-Jan-12 13:54 
QuestionSocket server handling MySQL queries from clients and return the response to them Pin
Islorvat27-Jan-12 4:48
Islorvat27-Jan-12 4:48 
AnswerRe: Socket server handling MySQL queries from clients and return the response to them Pin
Richard Andrew x6427-Jan-12 7:30
professionalRichard Andrew x6427-Jan-12 7:30 
AnswerRe: Socket server handling MySQL queries from clients and return the response to them Pin
SledgeHammer0127-Jan-12 13:25
SledgeHammer0127-Jan-12 13:25 
Questionconnecting external msSQL Pin
nuyts K27-Jan-12 4:41
nuyts K27-Jan-12 4:41 
AnswerRe: connecting external msSQL Pin
Eddy Vluggen27-Jan-12 6:11
professionalEddy Vluggen27-Jan-12 6:11 
Questiondotnetbar gauge control Pin
isang puntos27-Jan-12 4:36
isang puntos27-Jan-12 4:36 

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.