"Task" does not contain definition for "CompletedTask" for C #
I am following the tutorial at https://discord.foxbot.me/docs/guides/getting_started/intro.html in tee and still I get an error when I try to use
return Task.CompletedTask
and i am getting this error
'Task' does not contain a definition for 'CompletedTask'
I AM
using System.Threading.Tasks
+3
source to share
3 answers
Task.CompletedTask
is a static property added in .NET 4.6. Here is his source and here is his MSDN page that shows the minimum version of the framework.
Just for completeness, this is how you change the version of the .NET Framework you are using in your project.
+9
source to share
From this documentation , the Log () function has two parameters (LogMessage, Task). I believe there is a mistake in the tutorial and they forgot to enable the Task parameter. I would suggest using this instead.
private Task Log(LogMessage msg,Task task)
{
Console.WriteLine(msg.ToString());
return Task.CompletedTask;
}
0
source to share