This question is an exact duplicate:
there is a method, I have been wondering for the third day how to remake it under .net3.5. Libraries cannot be used. Or another solution may be needed here.
ConcurrentQueue<KeyValuePair<int, byte[]>> queue_block = new ConcurrentQueue<KeyValuePair<int, byte[]>>(); public static void ADD_Block_to_Queue(Queue<KeyValuePair<int,byte[]>> queue_block,Stream fs) { foreach (KeyValuePair<int, byte[]> block in Read_Blockk(fs)) { queue_block.Enqueue(block); while (queue_block.Count > 100) { var t = Task.Run(async delegate { await Task.Delay(1000); return 42; }); t.Wait(); } } }