Click here to Skip to main content
15,893,790 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a producer thread and a consumer thread in C#.
The producer should be able to tell the cosumer (trigger) that he has produced (I don't want the consumer to do polling), so the consumer's consumption is activated by an action on the producer's behalf.

I know it's not a complicated case but I am not a C# pro; I'd like to hear the opinion of CoPro's experts on the best approach to take, or the best options.
Posted

 
Share this answer
 
Comments
Herbisaurus 3-Mar-15 4:42am    
tnx Richard, I see that this link is labeled "Visual Studio .NET 2003".

Are you familiar with the latest thread and Task libraries to know if they offer out-of-the-box implementations for this?
Richard MacCutchan 3-Mar-15 5:01am    
Sorry, no. But you could probably search MSDN for the answer.
There's a good (and extensive) tutorial on C# threads/threading by Albahari that many have found useful: [^]

I bookmarked this answer to a CP QA question by Sander Rossell from 2012 [^]; it is a useful collection of links to major articles on C# threading from a variety of sources, including links to information the Task Parallel Library, Reactive Extensions, and other newer features on .NET.

In 2014, one of my favorite .NET gurus, Eric Lippert, wrote what I think is a great "wake-up" call that challenges ideas many programmers have about threads in .NET. I suggest you study it: [^].
 
Share this answer
 

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