Skip to content

Commit 674d4d7

Browse files
.net 8 - tasks #203
1 parent 2cd88b7 commit 674d4d7

File tree

9 files changed

+18
-19
lines changed

9 files changed

+18
-19
lines changed

1_CS/Tasks/AsyncStreams/AsyncStreams.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/Tasks/AsyncWindowsDesktopApp/AsyncWindowsDesktopApp/AsyncWindowsDesktopApp.csproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
4-
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
4+
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
55
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
66
<RootNamespace>AsyncWindowsDesktopApp</RootNamespace>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<Platforms>x86;x64;arm64</Platforms>
9-
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
10-
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
9+
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
10+
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
1111
<UseWinUI>true</UseWinUI>
12-
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
12+
<EnableMsixTooling>true</EnableMsixTooling>
1313
<Nullable>enable</Nullable>
1414
</PropertyGroup>
1515

@@ -24,8 +24,8 @@
2424
</ItemGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
28-
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
27+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.250108002" />
28+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
2929
<Manifest Include="$(ApplicationManifest)" />
3030
</ItemGroup>
3131

1_CS/Tasks/AsyncWindowsDesktopApp/AsyncWindowsDesktopApp/MainWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,5 @@ async Task DelayAsync()
119119
}
120120
}
121121

122-
private string GetThread() => $"thread: {Thread.CurrentThread.ManagedThreadId}";
122+
private string GetThread() => $"thread: {Environment.CurrentManagedThreadId}";
123123
}

1_CS/Tasks/ErrorHandling/ErrorHandling.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/Tasks/TaskBasedAsyncPattern/TaskBasedAsyncPattern.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/Tasks/TaskCancellation/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Task RunTaskAsync(CancellationToken cancellationToken) =>
2323
cancellationToken.ThrowIfCancellationRequested();
2424
}
2525
}
26-
});
26+
}, cancellationToken);

1_CS/Tasks/TaskCancellation/TaskCancellation.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

1_CS/Tasks/TaskFoundations/Program.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.Net;
2-
using System.Threading;
32
using System.Runtime.CompilerServices;
43

54
record Command(string Option, string Text, Action Action);
65

76
class Program
87
{
98
private static readonly Command[] commands =
10-
{
9+
[
1110
new("-async", nameof(CallerWithAsync), CallerWithAsync),
1211
new("-awaiter", nameof(CallerWithAwaiter), CallerWithAwaiter),
1312
new("-cont", nameof(CallerWithContinuationTask), CallerWithContinuationTask),
@@ -16,7 +15,7 @@ class Program
1615
new("-comb2", nameof(MultipleAsyncMethodsWithCombinators2), MultipleAsyncMethodsWithCombinators2),
1716
new("-val", nameof(UseValueTask), UseValueTask),
1817
new("-casync", nameof(ConvertingAsyncPattern), ConvertingAsyncPattern)
19-
};
18+
];
2019

2120
static void Main(string[] args)
2221
{
@@ -70,7 +69,7 @@ private static async void ConvertingAsyncPattern()
7069
Stream stream = response.GetResponseStream();
7170
using StreamReader reader = new(stream);
7271
string content = reader.ReadToEnd();
73-
Console.WriteLine(content.Substring(0, 100));
72+
Console.WriteLine(content[..100]);
7473

7574
#pragma warning restore SYSLIB0014
7675
}
@@ -141,7 +140,7 @@ static Task<string> GreetingAsync(string name) =>
141140
return Greeting(name);
142141
});
143142

144-
private readonly static Dictionary<string, string> names = new();
143+
private readonly static Dictionary<string, string> names = [];
145144

146145
static async ValueTask<string> GreetingValueTaskAsync(string name)
147146
{
@@ -189,6 +188,6 @@ public static void TraceThreadAndTask(string info)
189188
{
190189
string taskInfo = Task.CurrentId == null ? "no task" : "task " + Task.CurrentId;
191190

192-
Console.WriteLine($"{info} in thread {Thread.CurrentThread.ManagedThreadId} and {taskInfo}");
191+
Console.WriteLine($"{info} in thread {Environment.CurrentManagedThreadId} and {taskInfo}");
193192
}
194193
}

1_CS/Tasks/TaskFoundations/TaskFoundations.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>

0 commit comments

Comments
 (0)