diff --git a/S7.Net/PlcAsynchronous.cs b/S7.Net/PlcAsynchronous.cs
index a58f6293..f75cf233 100644
--- a/S7.Net/PlcAsynchronous.cs
+++ b/S7.Net/PlcAsynchronous.cs
@@ -25,7 +25,7 @@ public partial class Plc
/// A task that represents the asynchronous open operation.
public async Task OpenAsync(CancellationToken cancellationToken = default)
{
- var stream = await ConnectAsync().ConfigureAwait(false);
+ var stream = await ConnectAsync(cancellationToken).ConfigureAwait(false);
try
{
await queue.Enqueue(async () =>
@@ -44,11 +44,16 @@ await queue.Enqueue(async () =>
}
}
- private async Task ConnectAsync()
+ private async Task ConnectAsync(CancellationToken cancellationToken)
{
tcpClient = new TcpClient();
ConfigureConnection();
+
+#if NET5_0_OR_GREATER
+ await tcpClient.ConnectAsync(IP, Port, cancellationToken).ConfigureAwait(false);
+#else
await tcpClient.ConnectAsync(IP, Port).ConfigureAwait(false);
+#endif
return tcpClient.GetStream();
}
diff --git a/S7.Net/S7.Net.csproj b/S7.Net/S7.Net.csproj
index 85ef368c..fa85b08c 100644
--- a/S7.Net/S7.Net.csproj
+++ b/S7.Net/S7.Net.csproj
@@ -1,7 +1,7 @@
- net452;netstandard2.0;netstandard1.3
+ net452;netstandard2.0;netstandard1.3;net5.0
true
Properties\S7.Net.snk
S7.Net.UnitTest
diff --git a/appveyor.yml b/appveyor.yml
index 3e3100df..28da709e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,4 +1,4 @@
-image: Visual Studio 2019
+image: Visual Studio 2022
configuration: Release
install:
- choco install gitversion.portable -y