c#| Stream.WriteAsync()vs BeginWrite() [英] c# | Stream.WriteAsync() vs BeginWrite()
问题描述
Hello Guys,
我是C#流式异步编程的新手
Stream.WriteAsync()和Stream.BeginWrite()
之间有什么区别,因为我知道两者都是异步执行的。
我应该何时使用其中一个 (特别是如果我,上传文件并且有很多
并发 用户)
谢谢
原始日子我们使用BeginWrite来执行异步请求。但是,所有这些都已经过时,而不是使用Task和async / await。这就是WriteAsync的用途。在现代代码中,没有理由使用BeginWrite。
请参阅
MSDN 有关如何使用WriteAsync和async / await来编写数据而不阻塞调用线程的示例。
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
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.
这篇关于c#| Stream.WriteAsync()vs BeginWrite()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!