diff --git a/Examples/Program_DownloadSavedMedia.cs b/Examples/Program_DownloadSavedMedia.cs
index 72c1f2b..e431d36 100644
--- a/Examples/Program_DownloadSavedMedia.cs
+++ b/Examples/Program_DownloadSavedMedia.cs
@@ -11,7 +11,7 @@ namespace WTelegramClientTest
static async Task Main(string[] _)
{
Console.WriteLine("The program will download photos/medias from messages you send/forward to yourself (Saved Messages)");
- using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
+ await using var client = new WTelegram.Client(Environment.GetEnvironmentVariable);
var user = await client.LoginUserIfNeeded();
client.OnUpdates += Client_OnUpdates;
Console.ReadKey();
diff --git a/Examples/Program_GetAllChats.cs b/Examples/Program_GetAllChats.cs
index 6e4a9c2..f9ce1ce 100644
--- a/Examples/Program_GetAllChats.cs
+++ b/Examples/Program_GetAllChats.cs
@@ -24,7 +24,7 @@ namespace WTelegramClientTest
static async Task Main(string[] _)
{
- using var client = new WTelegram.Client(Config);
+ await using var client = new WTelegram.Client(Config);
var user = await client.LoginUserIfNeeded();
Console.WriteLine($"We are logged-in as {user.username ?? user.first_name + " " + user.last_name} (id {user.id})");
diff --git a/Examples/Program_Heroku.cs b/Examples/Program_Heroku.cs
index f1f9cbe..5ae5fe7 100644
--- a/Examples/Program_Heroku.cs
+++ b/Examples/Program_Heroku.cs
@@ -28,7 +28,7 @@ namespace WTelegramClientTest
var store = new PostgreStore(Environment.GetEnvironmentVariable("DATABASE_URL"), Environment.GetEnvironmentVariable("SESSION_NAME"));
// if DB does not contain a session yet, client will be run in interactive mode
Client = new WTelegram.Client(store.Length == 0 ? null : Environment.GetEnvironmentVariable, store);
- using (Client)
+ await using (Client)
{
Client.OnUpdates += Client_OnUpdates;
My = await Client.LoginUserIfNeeded();
diff --git a/Examples/Program_ListenUpdates.cs b/Examples/Program_ListenUpdates.cs
index 05f7f28..59abe49 100644
--- a/Examples/Program_ListenUpdates.cs
+++ b/Examples/Program_ListenUpdates.cs
@@ -16,7 +16,7 @@ namespace WTelegramClientTest
Console.WriteLine("The program will display updates received for the logged-in user. Press any key to terminate");
WTelegram.Helpers.Log = (l, s) => System.Diagnostics.Debug.WriteLine(s);
Client = new WTelegram.Client(Environment.GetEnvironmentVariable);
- using (Client)
+ await using (Client)
{
Manager = Client.WithUpdateManager(Client_OnUpdate/*, "Updates.state"*/);
My = await Client.LoginUserIfNeeded();
diff --git a/Examples/Program_ReactorError.cs b/Examples/Program_ReactorError.cs
index 83c2d6f..d84b8a0 100644
--- a/Examples/Program_ReactorError.cs
+++ b/Examples/Program_ReactorError.cs
@@ -20,7 +20,7 @@ namespace WTelegramClientTest
}
finally
{
- Client?.Dispose();
+ if (Client != null) await Client.DisposeAsync();
}
}
@@ -42,7 +42,7 @@ namespace WTelegramClientTest
while (true)
{
Console.WriteLine("Disposing the client and trying to reconnect in 5 seconds...");
- Client?.Dispose();
+ if (Client != null) await Client.DisposeAsync();
Client = null;
await Task.Delay(5000);
try
diff --git a/src/Client.cs b/src/Client.cs
index d470309..5f9fdea 100644
--- a/src/Client.cs
+++ b/src/Client.cs
@@ -20,7 +20,10 @@ using static WTelegram.Encryption;
namespace WTelegram
{
- public partial class Client : IDisposable, IAsyncDisposable
+ public partial class Client : IDisposable
+#if NETCOREAPP2_1_OR_GREATER
+ , IAsyncDisposable
+#endif
{
/// This event will be called when unsollicited updates/messages are sent by Telegram servers
/// Make your handler , or return or
See Examples/Program_ReactorError.cs for how to use this
or Examples/Program_ListenUpdate.cs using the UpdateManager class instead