Functional C#: Embracing Functional Programming in a C# World (C# Functional Book 1) by Bueno Carlos
Author:Bueno, Carlos
Language: eng
Format: epub
Published: 2023-05-06T00:00:00+00:00
In this example, weâve used Query Syntax to find the best flight fares from two different airlines. Weâve also utilized custom extension methods to fetch flight data and keep our code functional and clean.
To make the previous code work in parallel, we can use the AsParallel() extension method from the System.Linq.ParallelEnumerable class. This method enables parallelization of query execution, which can help to improve performance for large data sets and complex operations.
First, we need to add the System.Linq and System.Threading.Tasks namespaces to our extension methods class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Now, letâs modify the AirlineExtensions class to return Task<IEnumerable> instead of IEnumerable. Weâll use Task.Run() to simulate asynchronous API calls for fetching flight data:
public static class AirlineExtensions
{
public static Task<IEnumerable<Flight>> GetFlightsFromAirline1Async(this string origin)
{
return Task.Run(() =>
{
// Simulate asynchronous API call with Task.Delay
Task.Delay(500).Wait();
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(11922)
Hello! Python by Anthony Briggs(9386)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9352)
The Mikado Method by Ola Ellnestam Daniel Brolund(9321)
Dependency Injection in .NET by Mark Seemann(8866)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7859)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7350)
Grails in Action by Glen Smith Peter Ledbrook(7304)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7124)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5969)
Kotlin in Action by Dmitry Jemerov(4653)
Practical Vim (for Kathryn Amaral) by Drew Neil(3732)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3600)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3447)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3252)
Learning Java by Patrick Niemeyer & Daniel Leuck(2873)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2845)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(2834)
Microservices with Go by Alexander Shuiskov(2624)