c#| Stream.WriteAsync()vs BeginWrite() [英] c# | Stream.WriteAsync() vs BeginWrite()

查看:611
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆