-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathMethodWithUsing.cs
More file actions
40 lines (34 loc) · 758 Bytes
/
Copy pathMethodWithUsing.cs
File metadata and controls
40 lines (34 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Fody;
public class MethodWithUsing
{
[ConfigureAwait(false)]
public async Task AsyncMethod()
{
using(await NewMethod()){}
}
static async Task<IDisposable> NewMethod()
{
await Task.Delay(0);
return new MyDisposable();
}
#if NET
[ConfigureAwait(false)]
public async Task AsyncMethod_WithValueTask()
{
using(await new ValueTask<IDisposable>(NewMethod_WithValueTask())){}
}
static async Task<IDisposable> NewMethod_WithValueTask()
{
await new ValueTask(Task.Delay(0));
return new MyDisposable();
}
#endif
}
public class MyDisposable : IDisposable
{
public void Dispose()
{
Disposed = true;
}
public static bool Disposed;
}