Click here to Skip to main content
16,011,120 members
Home / Discussions / C#
   

C#

 
GeneralRe: Copy files across networked servers Pin
stateyama4-Dec-03 6:57
stateyama4-Dec-03 6:57 
GeneralTextBox Arrays Pin
spindar3-Dec-03 13:33
spindar3-Dec-03 13:33 
GeneralRe: TextBox Arrays Pin
Colin Angus Mackay3-Dec-03 15:03
Colin Angus Mackay3-Dec-03 15:03 
GeneralRe: TextBox Arrays Pin
Nick Seng3-Dec-03 15:40
Nick Seng3-Dec-03 15:40 
GeneralRe: TextBox Arrays Pin
Heath Stewart4-Dec-03 4:28
protectorHeath Stewart4-Dec-03 4:28 
GeneralWaiting for threads finish question Pin
clayne3-Dec-03 12:48
clayne3-Dec-03 12:48 
GeneralRe: Waiting for threads finish question Pin
Heath Stewart4-Dec-03 4:26
protectorHeath Stewart4-Dec-03 4:26 
GeneralRe: Waiting for threads finish question Pin
clayne4-Dec-03 8:37
clayne4-Dec-03 8:37 
Thanks for all the information But I am still a little confused. The seaThread.join line stops the current thread from processing till the seaThread finishes. That is what I want and since I have already started the ilThread, shouldn't it continue to run. the ilThread.join will hold the main thread in case it takes longer. I do want the main processing to stop till both threads finish.

I have looked into the threadpool a bit but find it just as confusing. I don't think my task really that complicated. How will thread pooling help me there?

For simplicity sake, I tried this with just a console program and it is working as I would expect. It is below.
<br />
using System;<br />
using System.Threading;<br />
<br />
namespace test_multithreading<br />
{<br />
	/// <summary><br />
	/// Summary description for Class1.<br />
	/// </summary><br />
	class Class1<br />
	{<br />
		public static void PrintCurDateTime()<br />
		{ <br />
			Console.WriteLine( " Secondary Thread Started" );<br />
			for (int i = 1; i <= 10; i++)<br />
			{<br />
				Console.WriteLine(" Second Thread working");<br />
				Thread.Sleep(1985);<br />
			}<br />
			Console.WriteLine( " Second Thread time: " + DateTime.Now.ToLongTimeString() );<br />
			Console.WriteLine( " Second Thread Finished" );<br />
		} <br />
		public static void PrintFutureDateTime()<br />
		{ <br />
			Console.WriteLine( "  Third Thread Started" );<br />
			for (int i = 1; i <= 100; i++)<br />
			{<br />
				Console.WriteLine("  Third Thread working");<br />
				Thread.Sleep(93);<br />
			}<br />
			Console.WriteLine( "  Third Thread time: " + DateTime.Now.ToLongTimeString() );<br />
			Console.WriteLine( "  Third Thread Finished" );<br />
		} <br />
		public static int Main(String[] args)<br />
		{<br />
			Console.WriteLine("Main Thread \n");<br />
<br />
			try<br />
			{<br />
				Thread futThread = new Thread(new ThreadStart( PrintFutureDateTime ));<br />
				futThread.Priority = ThreadPriority.Highest;<br />
				futThread.Start();<br />
<br />
				Thread secThread = new Thread(new ThreadStart( PrintCurDateTime ));<br />
				secThread.Priority = ThreadPriority.Highest;<br />
				secThread.Start();<br />
<br />
				Console.WriteLine("Waiting for theads to join");<br />
				secThread.Join();<br />
				futThread.Join();<br />
				Console.WriteLine("Joined");<br />
		<br />
				Console.WriteLine( "Main Thread time: " + DateTime.Now.ToLongTimeString() );<br />
				<br />
			}<br />
			catch (Exception e) <br />
			{<br />
				Console.WriteLine( e.ToString());<br />
			}<br />
			return 0;<br />
		} <br />
	}<br />
}<br />

QuestionHow to play audio files ? Pin
pahluwalia3-Dec-03 5:31
pahluwalia3-Dec-03 5:31 
AnswerRe: How to play audio files ? Pin
Heath Stewart3-Dec-03 6:29
protectorHeath Stewart3-Dec-03 6:29 
GeneralRichTextBox contents in a DB Pin
phimix3-Dec-03 5:19
phimix3-Dec-03 5:19 
GeneralRe: RichTextBox contents in a DB Pin
Heath Stewart3-Dec-03 6:27
protectorHeath Stewart3-Dec-03 6:27 
GeneralRe: RichTextBox contents in a DB Pin
Joel Lucsy3-Dec-03 8:43
Joel Lucsy3-Dec-03 8:43 
GeneralRe: Creating a new database... Pin
Heath Stewart3-Dec-03 5:15
protectorHeath Stewart3-Dec-03 5:15 
GeneralCreating a new database... Pin
Amirjalaly3-Dec-03 5:09
Amirjalaly3-Dec-03 5:09 
QuestionHow to display text the same way as printed? Pin
Loke13-Dec-03 3:59
Loke13-Dec-03 3:59 
GeneralCultureInfo Pin
Member 7439443-Dec-03 2:43
Member 7439443-Dec-03 2:43 
GeneralRe: CultureInfo Pin
Heath Stewart3-Dec-03 4:30
protectorHeath Stewart3-Dec-03 4:30 
GeneralDataBinding Row DataGrid Pin
Braulio Dez3-Dec-03 2:32
Braulio Dez3-Dec-03 2:32 
GeneralRe: DataBinding Row DataGrid Pin
Heath Stewart3-Dec-03 4:15
protectorHeath Stewart3-Dec-03 4:15 
GeneralRe: DataBinding Row DataGrid Pin
Braulio Dez3-Dec-03 21:06
Braulio Dez3-Dec-03 21:06 
Generalchat server Pin
Mahmoud Manasrah3-Dec-03 1:20
sussMahmoud Manasrah3-Dec-03 1:20 
Generalchat server Pin
Mahmoud Manasrah3-Dec-03 1:19
sussMahmoud Manasrah3-Dec-03 1:19 
GeneralRe: chat server Pin
Heath Stewart3-Dec-03 3:57
protectorHeath Stewart3-Dec-03 3:57 
GeneralRe: chat server Pin
Mahmoud Manasrah3-Dec-03 20:50
sussMahmoud Manasrah3-Dec-03 20:50 

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.