What's the idea that compiler gives warnings about asyncs:
public async void AddButton() { int found = -1; ... Task<int> findName = CheckNameAsync(FirstName, LastName);<other stuff> found = await findName; ... } async Task<int> CheckNameAsync(string first, string last) { int found = -1; Console.WriteLine("CheckNameAsync"); using (var ctx = new NorthwindEntities()) { foreach (Employee emp in ctx.Employees.Select(c => c)) { if ((emp.FirstName == first) && (emp.LastName == last)) { found = emp.EmployeeID; } } } await Task.Delay(1000); return found; }
This is fine, but if I comment the line "await Task.Delay(1000)" I get a warning:
[quote]
Warning 1 This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. C:\Users\xxx\Documents\Visual Studio 2012\Projects\NorthwindCaliburn\NorthwindCaliburn\ViewModels\EmpAddViewModel.cs 296 25 NorthwindCaliburn
[/quote]
Why does the compile thing there needs to be some waiting involved to cause delay that calls for asynchronity? Especially when the compiler may not know the internals of some library function that may internally do some waiting.
Also, what does zero delay value do? The documentation doesn't tell.
Does it yield, or maybe it has no effect at all?