Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //When I run this method, it is used in Task.WhenAny() with more such instances (I'm trying to tap into streams in proxy to log what's flowing).
- //This method throws IndexOutOfRangeException on readable[i].CopyToAsync(outputStreams[i]) - Debugger shows value of 'i' in time of execution is 2 (outputStreams.Length is 2).
- //Shouldn't lambda exception store the value of 'i' from time of declaration, instead of finding the current value (which might not exist already)?
- public static Task MultiplyStream(this Stream inputStream, params Stream[] outputStreams)
- {
- var splitStream = new ReadableSplitStream(inputStream);
- var tasks = outputStreams.Select(x => Task.Run(() => splitStream.GetForwardReadOnlyStream().CopyToAsync(x))).ToList();
- splitStream.StartReadAHead();
- return Task.WhenAll(tasks);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement