CSharp examples for System:DateTime
Waiting up to firstItemTimeout for the first item to become available, then return all other items that are immediately available.
using System.Threading; using System.Collections.Generic; using System.Collections.Concurrent; using System;/*from w w w . ja va 2 s .c o m*/ public class Main{ /// <summary> /// Waiting up to <paramref name="firstItemTimeout">firstItemTimeout</paramref> /// for the first item to become available, then return all other items that /// are immediately available. /// </summary> public static void TakeAvailable<T>(this BlockingCollection<T> collection, IList<T> destination, TimeSpan firstItemTimeout) { T item; var timeout = firstItemTimeout; while (collection.TryTake(out item, timeout)) { destination.Add(item); timeout = TimeSpan.Zero; } } }