问题
I recently completed a library for a online storage website that allows for me to call the PHP exposed RESTs between the file storage website and a windows form desktop client + Outlook add in.
Now, here is a question that has the code sample for the most basic operation in the library: Gracefully killing a TPL Task. I'm linking it for reference only. My next objective is a Windows Phone 7 client.
I knew I simply cannot use the same library as I need a different kind of class library for a WP7 app. So i went forward and created a WP7 version of the library hoping most of the stuff will work. I hit a road block immediately when I realized that I don't have access to the most critical class: a TPL Task.
Am I missing something here? Any advice? Thanks.
回答1:
OK. Apparently, there is no official System.Threading.Tasks for a WP7 project. However, after getting proper sleep and searching again, i found that a package exists at NuGet that simply answers all my needs: Task Parallel Library for Silverlight. The version is at 2.1.2 at the time of writing.
回答2:
Since Hasan answered the question, an official way has popped up. If you are targetting Windows Phone 7.5, the new official way of doing it would be to get the Microsoft.Bcl. This also works for .NET Framework 4 and Silverlight 4/5. I have only personally used it for .NET Portable Class Libraries and Windows Phone projects.
Microsoft.Bcl is available on the Nuget website or by running this command in your Package Manager console.
Install-Package Microsoft.Bcl
来源:https://stackoverflow.com/questions/8286539/unable-to-use-system-threading-tasks-in-wp7-application