Queue Data to another thread

M

Maanu

Hi,

I have two threads thread1 and thread2. Thread1 will give queue some data so
that Thread2 will process the queued data.

What mechanisms are available in c# for doing this?

Thanks!
 
P

Peter Duniho

Maanu said:
Hi,

I have two threads thread1 and thread2. Thread1 will give queue some data so
that Thread2 will process the queued data.

What mechanisms are available in c# for doing this?

There is nothing built-in per se. But, a basic implementation will make
use of the System.Collections.Generic.Queue<T> class, the Monitor class,
and the "lock" statement (which implicitly uses the Monitor class).

If you use Google Groups to search this newsgroup for past discussions
on the question, you'll come up with a wealth of information, including
various code examples. See also "producer/consumer pattern" (in this
newsgroup and elsewhere).

Pete
 

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

Similar Threads

Communication between threads 1
thread join question 5
Monitor.Pulse question 2
Threads very slow 5
basic threading question 2
.NET Threading Question 17
SMP and C# 2
Restarting a thread 13

Top