public int NonAsyncWithFixedBuffer() { TestReads tr = new TestReads(this.NumBytes); bool finished = false; int final = -1; while (!finished) { var(more, val) = tr.ReadNextWithFixedBuffer(); finished = !more; final = val; } return(final); }
public int RawBytesAndSpan() { TestReads tr = new TestReads(this.NumBytes); bool finished = false; int final = -1; while (!finished) { var(more, val) = tr.ReadNextWithSpan(this.NumBytes); finished = !more; final = val; } return(final); }
public int Async() { CancellationTokenSource cts = new CancellationTokenSource(); TestReads tr = new TestReads(this.NumBytes); bool finished = false; int final = -1; while (!finished) { var(more, val) = tr.ReadNextAsync(cts.Token).Result; finished = !more; final = val; } return(final); }
public int AsyncWithAwait() { int final = -1; return(DoItAsync().Result); async Task <int> DoItAsync() { CancellationTokenSource cts = new CancellationTokenSource(); TestReads tr = new TestReads(this.NumBytes); bool finished = false; while (!finished) { var(more, val) = await tr.ReadNextAsync(cts.Token); finished = !more; final = val; } return(final); } }