Last active
November 3, 2020 17:35
-
-
Save isaacabraham/76b675a39829c2f483214176be2f3286 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace ConsoleApp8 | |
{ | |
class Program | |
{ | |
static async Task<int> DoStuff() | |
{ | |
var x = await System.IO.File.ReadAllTextAsync("Foo"); | |
var y = await System.IO.File.ReadAllTextAsync("Bar"); | |
return x.Length + y.Length; | |
} | |
static void Main(string[] args) | |
{ | |
var lengths = DoStuff().Result; | |
Console.WriteLine($"Hello World! {lengths}"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let doStuff = async { | |
let! x = System.IO.File.ReadAllTextAsync "Foo" |> Async.AwaitTask | |
let! y = System.IO.File.ReadAllTextAsync "Bar" |> Async.AwaitTask | |
return x.Length + y.Length | |
} | |
let main args = | |
let lengths = doStuff |> Async.RunSynchronously | |
printf "Hello World! %d" lengths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharp.Control.Tasks.V2 | |
let doStuff () = task { | |
let! x = System.IO.File.ReadAllTextAsync "Foo" | |
let! y = System.IO.File.ReadAllTextAsync "Bar" | |
return x.Length + y.Length | |
} | |
let main args = | |
let lengths = doStuff().Result | |
printf "Hello World! %d" lengths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment