public void UsualTestBigFile()
        {
            readasync.ZeroingDictionary();
            var pathTxtFile = @"CrossinformTask/FileForTests/HarryPotterBigALotOfText.txt";

            var expected = "the, ing, and, rry, arr, Har, was, her, his, ere";

            var actual = readasync.ReadAllFileAsync(pathTxtFile, 1024, new CancellationToken());

            Assert.AreEqual(expected, actual.Result);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Stopwatch stopWatch = new Stopwatch();
            var       path      = @"FileForTests/BigFile.txt";
            var       readasync = new ParserFileMultithreaded();

            stopWatch.Start();
            var res = readasync.ReadAllFileAsync(path, 1024 * 10, tokenSource.Token).
                      ContinueWith(task =>
            {
                tokenSource.Cancel();
                return(task.Result);
            });

            var cancellationTask = Task.Run(() =>
            {
                Console.ReadKey(true);
                if (res.IsCompleted)
                {
                    return;
                }

                tokenSource.Cancel();
            }, tokenSource.Token);

            Console.WriteLine(res.Result);
            stopWatch.Stop();
            Console.WriteLine(stopWatch.ElapsedMilliseconds);
        }