I am working with the new Task Parallel Library and today set off in this case:
This code does not compile:
internal Task<Guid?> SavePages(string[] pages) { return Task.Run(() => { if (pages == null || pages.Length == 0) return null; ....
Unless I explicitly return a null nullable Guid:
internal Task<Guid?> SavePages(string[] pages) { return Task.Run(() => { if (pages == null || pages.Length == 0) return (Guid?)null; // Check documents path access
Why is this behavior I'm doing something wrong? I mean, I get the code to work with the second option, but I donβt know. If I use the library incorrectly, I mean that null is always null, right?
Compilation Error:
It is not possible to convert a lambda expression to the delegation type "System.Func" because part of the return types in the block are implicitly converted to the delegate return type
http://msdn.microsoft.com/en-us/library/dd460717.aspx
source share