Created
September 26, 2018 01:55
-
-
Save usausa/b2c7abf0693193eae579fd11427fe376 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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