.NET Core Background Tasks in F#

Currently, there is no way to generate a .NET Core Worker Service using F# as the language. The dotnet CLI does not expose the --language flag when running dotnet new worker.

Microsoft provides several examples of background workers in C#; I've ported these examples to F#, and made the code available on GitHub.

Since we can't generate a new worker service with F#, I created an F# console application with a dependency on Microsoft.Extensions.Hosting. I then build the IHost manually in the main function.

I've tried to convert the imperative C# code to functional F# where it makes sense. Another liberty I took was converting as much Task based code into Async<'a> wherever possible. There is still some Task based code around the edges, because of the .NET Core APIs.

I've done my best to write idiomatic F#; I'm new to the language, as well as to .NET Core, so pull requests against the repository are very welcome!