.NET 4.5 Parallel Extensions Cookbook by Unknown

.NET 4.5 Parallel Extensions Cookbook by Unknown

Author:Unknown
Language: eng
Format: mobi, epub
Publisher: Packt Publishing


By calling the GetConsumingEnumerable method of BlockingCollection, we can now use much cleaner foreach loop syntax.

Task.Factory.StartNew(() => { foreach (var item in result.GetConsumingEnumerable()) { Console.Write("\nConsuming item: {0}", item); } }); Console.ReadLine();

The GetConsumingEnumerable method takes a snapshot of the current state of the underlying collection and returns IEnumerable<T> for the collection items.

Performing LIFO operations with ConcurrentStack

ConcurrentStack is the thread safe counterpart of Systems.Collections.Generic.Stack, which is the standard Last-In-First-Out (LIFO) container in the .NET Framework. For algorithms that favor stack usage such as depth-first searches, a thread safe stack is a big benefit.

In this recipe we are going to take a look at the basic usage of ConcurrentStack. Our Console application for this recipe will initialize a range of data, which a simple producer Task will push onto the stack. Consumer Task will concurrently pop items from the stack and write them to Console.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(56785)
What's Done in Darkness by Kayla Perrin(26806)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(20673)
De Souza H. Master the Age of Artificial Intelligences. The Basic Guide...2024 by Unknown(20448)
D:\Jan\FTP\HOL\Work\Alien Breed - Tower Assault CD32 Alien Breed II - The Horror Continues Manual 1.jpg by PDFCreator(20445)
The Fifty Shades Trilogy & Grey by E L James(19310)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19262)
Shot Through the Heart by Mercy Celeste(19129)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17294)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(17229)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(17076)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16999)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16616)
The Subtle Art of Not Giving a F*ck by Mark Manson(14617)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14311)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13976)
Scorched Earth by Nick Kyme(12964)
Drei Generationen auf dem Jakobsweg by Stein Pia(11148)
Suna by Ziefle Pia(11076)
Scythe by Neal Shusterman(10557)