Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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);
- }
- }
Add Comment
Please, Sign In to add comment