Исходный код вики Сценарии
Версия 7.12 от Alexandr Fokin на 2024/03/10 13:55
Скрыть последних авторов
| author | version | line-number | content |
|---|---|---|---|
| |
7.4 | 1 | |(% style="width:399px" %)[[Имитация Async Deadlock>>doc:Разработка.NET.C#.Многопоточность и асинхронность.Сценарии.Имитация асинхронного (Async) Deadlock.WebHome]]|(% style="width:1094px" %) |
| 2 | |(% style="width:399px" %)[[Параллельность и асинхронность>>doc:.Параллельность и асинхронность.WebHome]]|(% style="width:1094px" %) | ||
| 3 | |(% style="width:399px" %)[[Пакетная обработка заявок с асинхронностью (Async)>>doc:.Пакетная обработка заявок с асинхронностью (Async).WebHome]]|(% style="width:1094px" %) | ||
| |
7.12 | 4 | |(% style="width:399px" %)OperationCanceledException|(% style="width:1094px" %){{code language="c#"}}try |
| 5 | { | ||
| 6 | // action | ||
| 7 | } | ||
| 8 | catch(Exception ex) | ||
| 9 | { | ||
| 10 | if ( | ||
| 11 | ex is OperationCanceledException oce | ||
| 12 | && oce.CancellationToken.Equals(cancellationToken) | ||
| 13 | ) | ||
| 14 | { | ||
| 15 | return; | ||
| 16 | } | ||
| 17 | |||
| 18 | // log | ||
| 19 | }{{/code}} | ||
| |
7.5 | 20 | |(% style="width:399px" %){{code language="C#"}}Task.Yield(){{/code}}|(% style="width:1094px" %)((( |
| |
7.4 | 21 | When would I use Task.Yield()? |
| |
7.3 | 22 | [[https:~~/~~/stackoverflow.com/questions/22645024/when-would-i-use-task-yield>>https://stackoverflow.com/questions/22645024/when-would-i-use-task-yield]] |
| |
1.2 | 23 | |
| |
7.4 | 24 | Async, recursion, and some weirdness in design of asynchronous API in C# |
| 25 | [[https:~~/~~/alexyakunin.medium.com/async-recursion-and-some-weirdness-of-design-of-asynchronous-api-in-c-vs-f-a5760a00a26a>>https://alexyakunin.medium.com/async-recursion-and-some-weirdness-of-design-of-asynchronous-api-in-c-vs-f-a5760a00a26a]] | ||
| |
7.6 | 26 | |
| 27 | Настройка приостановки и возобновления с помощью Yield и ConfigureAwait | ||
| |
7.10 | 28 | [[https:~~/~~/learn.microsoft.com/ru-ru/dotnet/standard/asynchronous-programming-patterns/consuming-the-task-based-asynchronous-pattern#configuring-suspension-and-resumption-with-yield-and-configureawait>>https://learn.microsoft.com/ru-ru/dotnet/standard/asynchronous-programming-patterns/consuming-the-task-based-asynchronous-pattern#configuring-suspension-and-resumption-with-yield-and-configureawait]] |
| |
7.11 | 29 | |
| 30 | Task.Yield() in library needs ConfigureWait(false) | ||
| 31 | [[https:~~/~~/stackoverflow.com/questions/28309185/task-yield-in-library-needs-configurewaitfalse>>https://stackoverflow.com/questions/28309185/task-yield-in-library-needs-configurewaitfalse]] | ||
| |
7.4 | 32 | ))) |
| |
7.8 | 33 | |(% style="width:399px" %)Задать размер стека для потока.|(% style="width:1094px" %)((( |
| 34 | Можно задать через параметр конструктора потока. | ||
| |
7.7 | 35 | Можно использовать для удобного тестирования логики (например рекурсии), которая может вызвать переполнение. |
| |
7.4 | 36 | |
| |
7.8 | 37 | RuntimeHelpers.TryEnsureSufficientExecutionStack Метод |
| 38 | [[https:~~/~~/learn.microsoft.com/ru-ru/dotnet/api/system.runtime.compilerservices.runtimehelpers.tryensuresufficientexecutionstack?view=netcore-3.0>>https://learn.microsoft.com/ru-ru/dotnet/api/system.runtime.compilerservices.runtimehelpers.tryensuresufficientexecutionstack?view=netcore-3.0]] | ||
| |
7.9 | 39 | |
| 40 | Why is stack size in C# exactly 1 MB? | ||
| 41 | [[https:~~/~~/stackoverflow.com/questions/28656872/why-is-stack-size-in-c-sharp-exactly-1-mb>>https://stackoverflow.com/questions/28656872/why-is-stack-size-in-c-sharp-exactly-1-mb]] | ||
| |
7.8 | 42 | ))) |
| 43 |