2

C# WinForms:

The Main goal is to have the fastest approach to read/write a huge file, like a 1 GB file. I know some about StreamReader and Threads in C# but I have also seen stuff about Async File I/O with C# but I haven't learned it yet. So my question is that does taking the approach of Async naturally provide a better performance over the normal StreamReader and multiple threads approach?

0

2 Answers 2

3

Using the async variants is probably a slightly lighter approach. The system handles the asynchronous read/writes for you and you don't have to create and manage a thread in your own code.

If in doubt, though, the usual advice applies: Measure! Write two test routines and test how well they perform.

Sign up to request clarification or add additional context in comments.

1 Comment

well first I wanted to know if Async helps with that or not. Because I don't know how to use Async so before spending time on Learning it I wanted to know if it is worth of time,,,
1

Well async also creates a background thread, but the plus side is that you will not have to manage it.

2 Comments

Ok so Async doesn't have performance and does the same as background thread but still it is easier to use because we don't have to worry about managing it.
Not too sure on the performance benefits (or lack thereof), but yes it will hide the actual implementation of performing code asynchronously away, freeing you of maintaining the thread related stuff. But definitely test the two procedures, see if there are any noticeable differences (I suspect there will not be much!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.