none
c# | Stream.WriteAsync() vs BeginWrite() RRS feed

  • Question

  • Hello Guys,

    I'm new to C# Streaming Async Programming 

    What's the difference between Stream.WriteAsync() and Stream.BeginWrite()

    as I know both are executed asynchronously .

    When should I use one over the other  (specially if i, uploading a file and There're  many concurrent  users )

    Thanks


    • Edited by ahmedeng89 Saturday, October 13, 2018 9:17 PM
    Saturday, October 13, 2018 9:17 PM

All replies

  • In the original days of .NET we used BeginWrite to do async requests. However all that has been obsoleted in lieu of using Task and async/await. That is what WriteAsync is for. In modern code there is no reason to use BeginWrite. 

    Refer to MSDN for an example of how you can use WriteAsync and async/await to write data without blocking the calling thread.


    Michael Taylor http://www.michaeltaylorp3.net

    Sunday, October 14, 2018 2:07 AM
    Moderator