diff --git a/.github/dev.yml b/.github/dev.yml index 542e9d0..7893558 100644 --- a/.github/dev.yml +++ b/.github/dev.yml @@ -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 diff --git a/EXAMPLES.md b/EXAMPLES.md index 290879e..ff86a4d 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -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._ + ## Upload a media file and post it with caption to a chat ```csharp diff --git a/src/UpdateManager.cs b/src/UpdateManager.cs index b9ee9db..cfd8053 100644 --- a/src/UpdateManager.cs +++ b/src/UpdateManager.cs @@ -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 GetInputChannel(long channel_id, MBoxState local) { if (channel_id <= 0) return null;