Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In C# in console application program i am in the middle of something where i have to perform 2 tasks at the same time..is there any way to do this??
pls help
Posted
Updated 21-Nov-15 20:54pm
v2
Comments
BillWoodruff 22-Nov-15 4:17am    
It would be helpful to know more about the "two things you want to do at the same time." Is there "communication" between the "two things" ? Synchronization ? What happens if one "thing" "finishes" before the other "thing" ?

We can't read your mind. It may be possible to simulate doing two things at the same time without using threads, but whether that's appropriate for your task, I am not sure.

1 solution

Yes: look at creating a Thread (or even two): Thread class[^]
There is a tutorial on threading here: https://msdn.microsoft.com/en-us/library/aa645740(v=vs.71).aspx[^] or there are loads of articles on the subject on this site: Google[^]
 
Share this answer
 
Comments
Palash Sachan 22-Nov-15 3:38am    
sir..i want to do 2 things at one time i means i want to use 2 different for loops at the same time in and it display in console..by using threading class is it possible??
OriginalGriff 22-Nov-15 3:45am    
Yes, that's the whole idea.
In order to execute any code, you need a thread - and if you want to execute two bits of code at the same time, each needs a separate thread (and an available core, but there are ways to simulate that and it's down to the system).
Have a look at the tutorial and you'll see that is what it is doing.
Palash Sachan 22-Nov-15 3:52am    
ok..reading it..will reply to you if have any problem..thanks for the reply sir
OriginalGriff 22-Nov-15 4:07am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900