Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 Cannot Use System.Threading.Tasks;

I am trying to execute some processes in parallel. and it is my first time doing that, upon trying : using System.Threading.Tasks; Tasks will be underlined in red saying :

The Type or namespace name "Tasks" does not exist in the namespace System.Threading(are you missing an assembly reference?)

how do i resolve that!?

like image 570
Ghassan Avatar asked Jan 19 '23 18:01

Ghassan


2 Answers

Does your project target .NET 3.5 or lower, perhaps? System.Threading.Tasks was introduced in .NET 4 - just using Visual Studio 2010 isn't enough; you need to target the appropriate framework. (Fortunately it is in the .NET 4 client profile, which is often a little "gotcha" for some other types.)

Likewise Silverlight hasn't yet got the TPL, although IIRC it's coming in Silverlight 5.

like image 122
Jon Skeet Avatar answered Jan 26 '23 02:01

Jon Skeet


Make sure that you are targeting .NET 4.0 in the properties of your project. TPL is not available in previous versions of .NET.

like image 22
Darin Dimitrov Avatar answered Jan 26 '23 03:01

Darin Dimitrov