异步的await task.run

编程入门 行业动态 更新时间:2024-10-27 00:32:05
本文介绍了异步的await task.run - 未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

VS2012,C#,XAML,的Windows Phone7应用程序(刚刚从Win7的迁移/ VS2010)。

VS2012, C#, XAML, Windows Phone7 app (just migrated from Win7/VS2010).

我刚刚迁移我的WP7应用的Win8 / VS2012。 (我的情况下,下面的问题可能表明,我可能会指向一个不正确的DLL提到这一点。)该应用程序迁移就好了。我在增加,我在VS2012原型一些额外的异步处理的过程和VS我遭到举报,以下是不正确的:

I've just migrated my WP7 app to Win8/VS2012. (I mention this in case the issue below might indicate that I may be pointing to an incorrect DLL.) The app migrated just fine. I'm in the process of adding some additional async processing that I prototyped in VS2012 and am getting flagged by VS that the following is incorrect:

var _Token = await Task.Run(() => (Token)_Serializer.ReadObject(_Response.GetResponseStream()));

VS是在说,System.Threading.Tasks.Task不包含'运行'的定义。参考在我的WP7应用程序分System.Threading.Tasks到此位置:\\包\\ Microsoft.Bcl.1.0.16-RC \\ LIB \\ SL4-windowsphone71 \\ System.Threading.Tasks.dll

VS is saying that "System.Threading.Tasks.Task does not contain a definition for 'Run'." The Reference for System.Threading.Tasks in my WP7 app points to this location: \packages\Microsoft.Bcl.1.0.16-rc\lib\sl4-windowsphone71\System.Threading.Tasks.dll

我添加了Microsoft.Bcl.1.0.16-RC通过的NuGet 完成迁移到VS2012。这是不正确? previously我使用AsyncCtpLibrary_Phone和被告知获得Microsoft.Bcl.Async就解决了构建错误,如:

I added the Microsoft.Bcl.1.0.16-rc via NuGet to complete the migration to VS2012. Was this incorrect? Previously I was using AsyncCtpLibrary_Phone and was advised that obtaining Microsoft.Bcl.Async would resolve the build errors such as:

该型'System.Threading.Tasks.Task'两个AsyncCtpLibrary_Phone.dll存在'>和C:\\ Program Files文件(x86)的\\参考大会\\微软\\框架\\ WindowsPhone的\\ 8.0 \\ mscorlib.dll中。  加入Microsoft.Bcl.Async WP7的应用程序正确建立追着。

The type 'System.Threading.Tasks.Task' exists in both AsyncCtpLibrary_Phone.dll' >and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\mscorlib.dll. After adding the Microsoft.Bcl.Async the wp7 app built correctly and ran.

这是我已经在VS2012的Task.Run出现问题仅原型尝试删除新的异步code后。

It was only after attempting to drop NEW async code I'd prototyped in VS2012 that the Task.Run issue arose.

在app.config包含此项:

The app.config contains this entry:

<dependentAssembly bcl:name="System.Threading.Tasks"> <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.5.11.0" newVersion="1.5.11.0" /> </dependentAssembly>

有一个额外的包,我需要安装?

Is there an additional package I need to install?

在此先感谢,保罗

Thanks in advance, Paul

推荐答案

在Microsoft.Bcl.Async,就像在异步CTP中,运行方法是在 TaskEx 类型,而不是工作。

In Microsoft.Bcl.Async, just like in the Async CTP, the Run method is on the TaskEx type instead of Task.

更多推荐

异步的await task.run

本文发布于:2023-11-03 07:43:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554599.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:await   task   run

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!