Skip to content

Commit 35bdf58

Browse files
committed
Refactor SampleLibrary to use common delay util method.
1 parent a820cbe commit 35bdf58

9 files changed

Lines changed: 21 additions & 32 deletions

File tree

SampleLibrary/A.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@ public class A
44
{
55
public async Task<int> CallA()
66
{
7-
System.Diagnostics.Debug.WriteLine("FuncOne started");
8-
9-
await Task.Delay(1000);
10-
11-
System.Diagnostics.Debug.WriteLine("FuncOne ended");
7+
await Utils.DebugDelay(nameof(CallA), 1000);
128

139
return await Task.FromResult(1);
1410
}
15-
16-
public int Blah() {
17-
return 5;
18-
}
1911
}

SampleLibrary/B.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ public class B
44
{
55
public async Task<int> CallB()
66
{
7-
System.Diagnostics.Debug.WriteLine("FuncTwo started");
8-
9-
await Task.Delay(1200);
10-
11-
System.Diagnostics.Debug.WriteLine("FuncTwo ended");
7+
await Utils.DebugDelay(nameof(CallB), 1200);
128

139
return await Task.FromResult(2);
1410
}

SampleLibrary/C.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ public class C
44
{
55
public async Task<int> CallC(int inputOne, int inputTwo)
66
{
7-
System.Diagnostics.Debug.WriteLine("FuncThree started");
8-
9-
await Task.Delay(1000);
10-
11-
System.Diagnostics.Debug.WriteLine("FuncThree ended");
7+
await Utils.DebugDelay(nameof(CallC), 1000);
128

139
return await Task.FromResult(inputOne + inputTwo);
1410
}

SampleLibrary/D.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ public class D
44
{
55
public async Task<int> CallD()
66
{
7-
System.Diagnostics.Debug.WriteLine("FuncFour started");
8-
9-
await Task.Delay(4000);
10-
11-
System.Diagnostics.Debug.WriteLine("FuncFour ended");
7+
await Utils.DebugDelay(nameof(CallD), 4000);
128

139
return await Task.FromResult(4);
1410
}

SampleLibrary/E.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ public class E
44
{
55
public async Task<int> CallE(int input)
66
{
7-
System.Diagnostics.Debug.WriteLine("FuncFour started");
8-
9-
await Task.Delay(1000);
10-
11-
System.Diagnostics.Debug.WriteLine("FuncFour ended");
7+
await Utils.DebugDelay(nameof(CallE), 1000);
128

139
return await Task.FromResult(5 + input);
1410
}

SampleLibrary/F.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class F
44
{
55
public async Task<int> CallF(int inputOne, int inputTwo)
66
{
7-
System.Diagnostics.Debug.WriteLine("FuncFinal started");
7+
await Utils.DebugDelay(nameof(CallF), 0);
88
return await Task.FromResult(inputOne + inputTwo);
99
}
1010
}

SampleLibrary/OrchestratorSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace SampleLibrary;
44

55
[AsyncTaskOrchestrator]
6-
internal class OrchestratorSpec
6+
public class OrchestratorSpec
77
{
88
private readonly A a;
99
private readonly B b;

SampleLibrary/SampleLibrary.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

SampleLibrary/Utils.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace SampleLibrary;
2+
3+
internal class Utils
4+
{
5+
public static async Task DebugDelay(string functionName, int delayTime)
6+
{
7+
System.Diagnostics.Debug.WriteLine($"{functionName} started");
8+
9+
await Task.Delay(delayTime);
10+
11+
System.Diagnostics.Debug.WriteLine($"{functionName} ended");
12+
}
13+
}

0 commit comments

Comments
 (0)