Manager: added opportunity to call DropPendingUpdates/StopResync before a resync

This commit is contained in:
Wizou 2024-07-30 01:50:26 +02:00
parent 9712233c00
commit 8654f99d2b
3 changed files with 16 additions and 1 deletions

2
.github/dev.yml vendored
View file

@ -1,7 +1,7 @@
pr: none
trigger: [ master ]
name: 4.1.5-dev.$(Rev:r)
name: 4.1.6-dev.$(Rev:r)
pool:
vmImage: ubuntu-latest

View file

@ -210,6 +210,8 @@ that simplifies the download of a photo/document/file once you get a reference t
See [Examples/Program_DownloadSavedMedia.cs](https://github.com/wiz0u/WTelegramClient/blob/master/Examples/Program_DownloadSavedMedia.cs?ts=4#L28) that download all media files you forward to yourself (Saved Messages)
_Note: To abort an ongoing download, you can throw an exception via the `progress` callback argument._
<a name="upload"></a>
## Upload a media file and post it with caption to a chat
```csharp

View file

@ -80,6 +80,7 @@ namespace WTelegram
goto newSession;
case NewSessionCreated when _client.User != null:
newSession:
await Task.Delay(HalfSec); // let the opportunity to call DropPendingUpdates/StopResync before a big resync
if (_local[L_PTS].pts != 0) await ResyncState();
else await ResyncState(await _client.Updates_GetState());
break;
@ -282,6 +283,18 @@ namespace WTelegram
finally { _sem.Release(); }
}
public async Task StopResync()
{
await _sem.WaitAsync();
try
{
foreach (var local in _local.Values)
local.pts = 0;
_pending.Clear();
}
finally { _sem.Release(); }
}
private async Task<InputChannel> GetInputChannel(long channel_id, MBoxState local)
{
if (channel_id <= 0) return null;