Skip to content

Instantly share code, notes, and snippets.

@usausa
Created September 26, 2018 01:55
Show Gist options
  • Save usausa/b2c7abf0693193eae579fd11427fe376 to your computer and use it in GitHub Desktop.
Save usausa/b2c7abf0693193eae579fd11427fe376 to your computer and use it in GitHub Desktop.
// Good
public static async Task<T> UseTemporary<T>(Func<string, Task<T>> func)
{
var path = Path.GetTempFileName();
try
{
return await func(path);
}
finally
{
File.Delete(path);
}
}
// Bad
public static Task<T> UseTemporary<T>(Func<string, Task<T>> func)
{
var path = Path.GetTempFileName();
try
{
return func(path);
}
finally
{
File.Delete(path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment