I think I'm missing something but I cant seem to get await to work in .net 4.5
Does anyone know the correct syntax here? everywhere I've looked seems to use exactly what I've got. (see Proper use of Task.Delay to delay key presses)
I think I'm missing something but I cant seem to get await to work in .net 4.5
Does anyone know the correct syntax here? everywhere I've looked seems to use exactly what I've got. (see Proper use of Task.Delay to delay key presses)
It looks like you're trying to invoke an asynchronous method from a lambda. You're probably missing the async
at the start. For example"
SomeMethod(async () =>
{
//...
await Task.Delay(1000, cancellationToken);
});
You need to put async
on your method...the one that encloses your block of code.