Async / waiting for compact framework v3.5 - manual implementation

I need to develop an application for WinCE 5.0 that connects / synchronizes data with a regular PC application that offers a web service with which I can talk with a mobile (industrial) device.

Since it is obvious that the code will be difficult to maintain on the side of the mobile device (check the connection β†’ after completion: check the availability of the web service β†’ upon completion: check if the mobile device is suitable for synchronization β†’ when the data exchange is completed) I would like to use the synchronous method programming with await s.

I found a few code snippets of Daniel Grunwald, which is the minimal implementation of the material needed by the compiler for the async / await function, Together with the Parallel Library Task for .Net 3.5 (which I had to slightly modify, because some methods that are not called do not exist with required signature), which, for example, implements a task type, looks promising.

So far, no solution has been created, because I lack the implementation of TaskCompletionSource . I decompiled recent mscorlib using ILSpy, but the code is not used - there are too many types to use that are not in CF.

At this point, I wonder if this project will fail because I will never run VS 2008 (which I have to use in ordner for target smart devices) in order to use the C # 5 compiler (maybe there is a workaround? ), or CF does not have decisive types for TaskCompletionSource (which I will probably need, since I want to make events expected), or that the TPL3.5 + Grunwald snippet + TCS implementation will be built, but will never work.

Can someone more experienced please appreciate my intentions? I would like to hear your comments, ideas and alternative approaches. Thanks.

Refresh Aaron Stainback message indicates that it should be possible to build CF 3.5 with VS2012. This should solve at least a problem with the compiler.

+7
source share
2 answers

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

But using async - await requires the compiler to support it, there is no way around this. This means that VS 2012 or perhaps VS 2010 with Async CTP (but I would not recommend this, not product quality). As far as I know, there is no way to make this work with VS 2008.

Another possibility is to use Mono, but I don’t know if it supports WinCE.

+2
source

You can use Visual Studio 2015 to compile in Compact Framework 3.5 by following these instructions:

  • Install "Redistributable .NET Compact Framework 3.5";
  • Copy files from 'C: \ Program Files (x86) \ Microsoft.NET \ SDK \ CompactFramework \ v3.5 \ WindowsCE';
  • Paste the files into the folder "C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework \ .NETFramework \ v3.5 \ Profile \ CompactFramework";
  • Create a directory named 'RedistList';
  • Create a file called "FrameworkList.xml" in the "RedistList" directory;
  • Set the following content for the generated file:

     <?xml version="1.0" encoding="utf-8"?> <FileList Redist="Net35-CF" Name=".NET Compact Framework 3.5"> </FileList> 

Now you can create a .NET Core Class Library project on Visual Studio 2015 and configure "net35-cf".

To use async / wait, you can use the System.Threading.Tasks.WindowsCE package.

An example project can be found at: https://github.com/WindowsCE/System.Collections.Concurrent/tree/08669ca5b45cc5c74c8c225a633828f9e26b5276

Disclaimer: I am the author of the package and project above.

+1
source

All Articles