异步/等待压缩框架v3.5-手动实现 [英] Async/await for compact framework v3.5 - manual implementation

查看:98
本文介绍了异步/等待压缩框架v3.5-手动实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须为WinCE 5.0开发一个应用程序,该应用程序与常规PC应用程序通信/同步数据,该应用程序提供了可以与移动(工业)设备进行通讯的Web服务。

I have to develop an application for WinCE 5.0 which communicates/synchronizes data with a regular PC application which offers a webservice I can talk to with my mobile (industrial) device.

因为很明显会导致在移动设备端难以维护的代码(检查连接→完成时:检查Web服务可用性→完成时:检查移动设备是否有资格进行同步→完成后开始交换数据)我想使用 await s的同步编程方式。

Since it is obvious to result in code which is hard to maintain on the mobile device side (check connection → when completed: check webservice availability → when completed: check whether mobile device is eligible for syncing → when completed start exchanging data) I would love to use the syncronous way of programming using awaits.

我发现了一些代码段是编译器用于async / await功能所需内容的最小实现。与 .NET 3.5的任务并行库一起使用(由于某些调用方法没有

I have found some code snippet by Daniel Grunwald which is a minimal implementation of the stuff needed by the compiler for the async/await feature. Together with Task Parallel Library for .Net 3.5 (which I had to change just slightly because some methods called do not exist with the signature required) which implements the Task type for instance, it looks promising.

到目前为止,该解决方案尚未构建,因为我缺少 TaskCompletionSource 。我用ILSpy反编译了最近的mscorlib,但是代码不可用-使用中的类型太多,CF中不存在。

So far the solution does not build, because I'm lacking the implementation of TaskCompletionSource. I decompiled the recent mscorlib with ILSpy, but the code is not usable - too many types in usage which are not present in CF.

这时我想知道这是否项目一定会失败,因为我永远不会说服VS 2008(我必须在ordner中使用它来定位智能设备)使用C#5编译器(也许有解决方法?),或者CF缺少TaskCompletionSource的关键类型(这可能是我可能需要的,因为我希望可以等待事件发生),或者可以构建TPL3.5 + Grunwald的代码段+ TCS实施,但实际上无法正常工作。

At this point I am wondering whether this project is bound to fail, because I will never convince VS 2008 (which I have to use in ordner to target smart devices) to use the C# 5 compiler (maybe there is a workaround?), or CF is lacking crucial types for TaskCompletionSource (which I probably will need since I want to make events awaitable), or that TPL3.5 + Grunwald's snippet + TCS implementation will build but never actually work.

还有其他人可以使用吗?有经验的请评价我的意图?很想听听您的意见,想法和替代方法。谢谢。

Can someone more experienced please appraise my intent? Would love to hear your comments, ideas and alternative approaches. Thanks.

更新 Aaron Stainback的帖子表示应该可以使用VS2012构建CF 3.5。至少应该可以解决编译器问题。

Update Aaron Stainback's post indicates it should be possible to build CF 3.5 with VS2012. That should tackle at least the compiler issue.

推荐答案

我认为添加对 async -等待到本机不支持的平台应该可行,因为这正是Microsoft.Bcl.Async对.Net 4.0所做的。

I think that adding support for async-await to a platform that doesn't natively support it should be doable, because that's exactly what Microsoft.Bcl.Async does for .Net 4.0.

但是使用 async - await 要求编译器支持它,没有办法解决。也就是说,VS 2012或可能是带有异步CTP的VS 2010(但我不建议这样做,这不是生产质量)。据我所知,没有办法在VS 2008上实现此功能。

But using async-await requires compiler that supports it, there is no way around that. That means VS 2012 or possibly VS 2010 with the Async CTP (but I wouldn't recommend that, it's not production quality). As far as I know, there is no way to make this work with VS 2008.

另一种可能性是使用Mono,但我不知道它是否支持WinCE。

One more possibility would be to use Mono, but I have no idea if it supports WinCE.

这篇关于异步/等待压缩框架v3.5-手动实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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