Posts

Showing posts with the label Asynchronous Programming

Donate

Return Multiple Values From C# Asynchronous Function

Good evening fellow developers! I have a simple application that queries the database and returns list of employees and list of their dependents. Since I've just started learning async programming, I wonder if I could return multiple values for an asynchronous function or method. The initial solution that I have is to create a view model class that has two properties specifically list of employees and list of dependents. And this view model class will be the return type of the function. After reading through the docs, it's possible to return multiple values using System.ValueTuple namespace. If the target framework of the project is 4.6.2 and below, you need to add the System.ValueTuple NuGet package using NuGet Console Manager or add the package using Manage NuGet Package tool. For now, lets install the package using console manager. Install-Package "System.ValueTuple" Next is to modify the existing method to return multiple values using System.ValueTuple. pr

Donate