private static void Export(int linesCount = 30) { var rnd = new Random(); var symbols = new string[] { "ABC", "DEF", "GHI", "JKL" }; int itemsTotal = linesCount; int itemsCountByLine = 3; if (itemsTotal < itemsCountByLine) { Console.WriteLine("Sorry :-("); return; } int counting = itemsTotal / itemsCountByLine; SetupPushBasedStreams(); var sub1 = ResponseStream .Buffer(itemsCountByLine) .Subscribe(xs => { StringBuilder sb = new StringBuilder(); sb.Append(symbols[rnd.Next(symbols.Length)]); foreach (var x in xs) { sb.AppendFormat(" {0,18:0.000000000000000}", x); } ReadyStreamW.OnNext(sb.ToString()); if (--counting == 0) { ReadyStreamW.OnCompleted(); } }); //var sub2 = ReadyStream.Subscribe(s => Console.WriteLine(s)); string path = @".\ExportedFile.txt"; var fileExporter = new FileExporter(path); var sub2 = ReadyStream.Subscribe(fileExporter); Send(itemsTotal, 10, 2); fileExporter.Wait(); sub2.Dispose(); sub1.Dispose(); }