News for hackers. Stuff that matters.
Re:Asynchronous Programming in C# by mrkeen on Tuesday April 30, 2024 @12:33PM (#40212903)
Of course.

In the article linked above: > ContinueWith allocates more than using async await

Does LINQ not carry a similar overhead?

Re:Asynchronous Programming in C# by pjc50 on Wednesday May 01, 2024 @04:12AM (#40220758)
You said, "So does C# not have map yet?", knowing full well that it did, and are now moving the goalposts.
Re:Asynchronous Programming in C# by mrkeen on Wednesday May 01, 2024 @07:45AM (#40221949)
I'll rephrase.

Does LINQ's map come with a plethora of problems like I'm told Task's map does above?

Should you avoid mapping because 'it's the old callback model' which doesn't belong in modern code?

Is map fit for purpose, or has it been disavowed?

Re:Asynchronous Programming in C# by pjc50 on Wednesday May 01, 2024 @09:19AM (#40222791)
Mapping (spelt "Select" quite often in LINQ) is entirely normal and promoted going forwards. It can optimize extremely well for simple cases. By default it is not parallel and compiles to an underlying for loop.

Or you can use it with Tasks. https://itnext.io/fun-csharp-doing-linq-to-tasks-because-tas...

(caution: contains the M word)

More from Microsoft: https://devblogs.microsoft.com/pfxteam/tasks-monads-and-linq... ; referencing Lippert https://ericlippert.com/category/monads/

ContinueWith is not a broken "map". What people usually want is Select. https://learn.microsoft.com/en-us/dotnet/csharp/linq/standar...