Replies: 2 comments
-
While https://github.com/StephenCleary/AsyncEx is one of the best options to call async code from sync code, avoiding most dead-locks. It still has some drawbacks. AFAIK there is no clean and safe solution in general. IMHO there should be a sync API, too. I'm not sure whether T4 is a good solution. Suggestion: Combine sync(-only) parser / helpers with sync+async I/O. Hopefully only a few methods need to be duplicated (same code, async+sync). |
Beta Was this translation helpful? Give feedback.
-
If sync support is dropped, it will become more difficult for consuming applications that are sync since sprinkling in async in an otherwise sync app tends to cause problems. |
Beta Was this translation helpful? Give feedback.
-
There is a single async call
TextReader.ReadAsync
. Because of the nature of async, everything all the way up the chain then needs to be async also. The only good way I've found of doing both sync and async together using the same code is to use T4 templates and reproduce the exact same method. This is annoying and error prone.Is there any reason why CsvHelper shouldn't just drop the sync methods on the async path?
Since the next version will be
netstandard2.1
only, most places this is used will probably have async built in and this won't be a problem. Solutions that still need to use sync for some reason could use Stephen Cleary's library https://github.com/StephenCleary/AsyncEx or one of the solutions listed here. https://stackoverflow.com/questions/9343594/how-to-call-asynchronous-method-from-synchronous-method-in-cThoughts?
Beta Was this translation helpful? Give feedback.
All reactions