A library which extends System.Task
with fluent syntax using LINQ convention.
using System;
using System.Task;
using MonTask;
namespace Example {
public static class Program {
public static void Main(string[] args) {
// Returns the lenght of the string given to method ExampleAsync
Task<int> select = ExampleAsync("Hello World").Select(str => str.Length);
}
public static Task<string> ExampleAsync(string txt) {
return Task.Run(() => txt);
}
}
}
using System;
using System.Task;
using MonTask;
namespace Example {
public static class Program {
public static void Main(string[] args) {
// Using map with a task will nest the task.
Task<Task<string>> select = ExampleAsync("Hello World").Select(str => ExampleAsync(str));
// Using flatmap will not nest the task.
Task<string> selectMany = ExampleAsync("Hello World").SelectMany(str => ExampleAsync(str));
}
public static Task<string> ExampleAsync(string txt) {
return Task.Run(() => txt);
}
}
}
using System;
using System.Task;
using MonTask;
namespace Example {
public static class Program {
public static void Main(string[] args) {
// Using map with a task will nest the task.
Task<Task> select = ExampleAsync().Select(() => ExampleAsync());
// Using flatmap will not nest the task.
Task selectMany = ExampleAsync().SelectMany(() => ExampleAsync());
}
public static Task ExampleAsync() {
return Task.Delay(1000);
}
}
}