Renamed Update event to OnUpdate, returning Task

(to gracefully handle async exceptions)
This commit is contained in:
Wizou 2022-07-29 15:24:18 +02:00
parent 6977641b2d
commit 668b19e3e8
8 changed files with 32 additions and 29 deletions

View file

@ -30,7 +30,7 @@ namespace WTelegramClientTest
Client = new WTelegram.Client(store.Length == 0 ? null : Environment.GetEnvironmentVariable, store);
using (Client)
{
Client.Update += Client_Update;
Client.OnUpdate += Client_OnUpdate;
My = await Client.LoginUserIfNeeded();
Console.WriteLine($"We are logged-in as {My.username ?? My.first_name + " " + My.last_name} (id {My.id})");
var dialogs = await Client.Messages_GetAllDialogs();
@ -39,7 +39,7 @@ namespace WTelegramClientTest
}
}
private static async void Client_Update(IObject arg)
private static async Task Client_OnUpdate(IObject arg)
{
if (arg is not UpdatesBase updates) return;
updates.CollectUsersChats(Users, Chats);