PC Review


Reply
Thread Tools Rate Thread

another question on setting up multi threads.

 
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      16th Feb 2005
Hi I have the code below and am trying to learn how to set up 2 threads and
have 1 thread wait for the completion of another thread. Just wondering or
there any simple examples, thought for one thread I would just use a loop and
when this loop ends have the second thread start to execute. The code I have
so far is minimal. I have a write to console start thread in the member that
is called for the thread start but this does not seem to executed.

using System;
namespace ConsoleApplication1
{
{
static void Main(string[] args)
{
System.Threading.Thread myThread;
start_thread start_thread_inst = new start_thread() ;
myThread = new System.Threading.Thread(new
System.Threading.ThreadStart(start_thread_inst.start ));//calling the start
method of class start_thread
myThread.Start() ;

}
}
}
In the class file I have
using System;
namespace ConsoleApplication1
class start_thread
{
public void start(){Console.WriteLine("start_thread");}
}
--
Paul G
Software engineer.
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      17th Feb 2005
Paul <(E-Mail Removed)> wrote:
> Hi I have the code below and am trying to learn how to set up 2 threads and
> have 1 thread wait for the completion of another thread.


Just use Thread.Join.

> Just wondering or there any simple examples


See http://www.pobox.com/~skeet/csharp/threads

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
=?Utf-8?B?UGF1bA==?=
Guest
Posts: n/a
 
      17th Feb 2005
ok thanks for the information.

"Jon Skeet [C# MVP]" wrote:

> Paul <(E-Mail Removed)> wrote:
> > Hi I have the code below and am trying to learn how to set up 2 threads and
> > have 1 thread wait for the completion of another thread.

>
> Just use Thread.Join.
>
> > Just wondering or there any simple examples

>
> See http://www.pobox.com/~skeet/csharp/threads
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WinForm and Multi threads rockdale Microsoft Dot NET Framework Forms 6 19th Oct 2009 02:10 PM
firing Multi-Threads sometimes misses jake Microsoft C# .NET 4 24th Jul 2008 06:41 PM
Multi page threads V_R Feedback 3 20th Aug 2007 09:53 PM
Terminating active threads in Multi-threaded application question =?Utf-8?B?TmF2ZWVuIE11a2tlbGxp?= Microsoft C# .NET 2 22nd Jun 2005 02:04 PM
How to disable multi-threads in C# ?? ?code Microsoft C# .NET 6 21st Dec 2004 04:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:28 AM.