AwaitWhat 1.1.0

dotnet add package AwaitWhat --version 1.1.0                
NuGet\Install-Package AwaitWhat -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AwaitWhat" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AwaitWhat --version 1.1.0                
#r "nuget: AwaitWhat, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AwaitWhat as a Cake Addin
#addin nuget:?package=AwaitWhat&version=1.1.0

// Install AwaitWhat as a Cake Tool
#tool nuget:?package=AwaitWhat&version=1.1.0                

AwaitWhat โ‰

banner

  • Forgotten if Task.Delay takes milliseconds or seconds?
  • Not happy with the readability of your new TimeSpan with a billion parameters?
  • Tired of coworkers understanding your code?
  • Then AwaitWhat is for you!

AwaitWhat is a .NET Standard 2.0 library that lets you await a String after you have installed the NuGet package. Yes, you read that right. Just a normal string. No configuration needed, just hit install. Write the TimeSpan format however you wantยน in the string, and just await it! How are you ever going to top the readability of plain english!?

Installation

Warning: If it wasn't clear already, you probably should not use this in production code. Like, you can use it, if you really want to. It works fine. But you probably, most certainly, definitely should not use it. I mean, just look at it. You're awaiting a String. That's not a Task. Shame on you!

  1. Install the NuGet Package, for example like this:
    dotnet add package AwaitWhat
    
  2. Done! Now you can await any String in your project. Enjoy!

Examples

Standard With AwaitWhat
await Task.Delay(1210) await "1.21s"
await Task.Delay(1210) await "1 second, 210 milliseconds"
await Task.Delay(1210) await "1210ms"
await Task.Delay(1210) await "0.02016667 MiNUteS"
... ...
await Task.Delay(new TimeSpan(1, 23, 9)); await "1h23m9s"
await Task.Delay(new TimeSpan(1, 23, 9)); await "1:23:09"
await Task.Delay(new TimeSpan(1, 23, 9)); await "1 hr 23 min 9 sec"
await Task.Delay(new TimeSpan(1, 23, 9)); await "1 hour, 23 minutes and 9 seconds"
... ...

You get the idea, check TimeSpanParser for all the valid formats.

Wait... what? How does this even work?

I got the idea from a wonderful video by the wonderful Nick Chapsas. Basically Microsoft has some weird internal compiler wizardry that is exposed and I used that to add an awaiter to String. Just watch the video ๐Ÿ‘‰๐Ÿ‘ˆ


<div id="foot1"></div>

ยน Okay, not however you want. If you mess it up too much you will get an ArgumentException. Like, don't await your email address, because I have no idea what you want me to do with that. We currently rely fully on the wonderful TimeSpanParser package, so go complain there if you don't like it give them some love!! ๐Ÿ˜ƒ

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 218 7/6/2023
1.0.0 157 7/5/2023

Offset delay from parsing the string