Threading and Events

G

Guest

Hi am writing an application which involves a long loop inside a loop. this
loop can work independently too. so i want to do something like this

for(int i=0;i<5000;i++){
if(some Condition){
raiseEvent
}
}

//in event handler
Thread t=new Thread(this.somemethod);
t.Start()l

//in somemethod
some very log process

So what are the problems i am going to run into.
Whats the better alternative
 
T

Tom Shelton

Hi am writing an application which involves a long loop inside a loop. this
loop can work independently too. so i want to do something like this

for(int i=0;i<5000;i++){
if(some Condition){
raiseEvent
}
}

//in event handler
Thread t=new Thread(this.somemethod);
t.Start()l

//in somemethod
some very log process

So what are the problems i am going to run into.
Whats the better alternative

Are these sub tasks long runing tasks? If they aren't, then I would
suggest maybe using the ThreadPool calss's QueueUserWorkItem method to
initiate queue the tasks you want to run....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top