首页 新闻 赞助 找找看

c# 5.0中的任务异步 await和 async如何处理 out 参数?

0
悬赏园豆:10 [已关闭问题] 关闭于 2013-09-10 18:59


大家好,我在编写一个异步框架的时候用到await和async关键字,我想知道如何写一个可等待的异步方法,且包含out输出参数,例如:

public void M1()
{
    int op;
    int result = GetData(out op);
}

这个方法我想改成任务异步的形式:

public async void M1()
{
    int op;
    int result = await GetDataTaskAsync(out op);
}

 

这里的GetDataTaskAsync方法应该如何写?能否给个例子,

 

~冻结~的主页 ~冻结~ | 初学一级 | 园豆:39
提问于:2013-09-10 17:59
< >
分享
所有回答(1)
0

任务异步方法不能使用ref或out参数!

http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx

 

“An async method can't declare ByRef parameters in Visual Basic or ref or out parameters in C#, but the method can call methods that have such parameters.”

~冻结~ | 园豆:39 (初学一级) | 2013-09-10 18:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册