Скрыть последних авторов
Alexandr Fokin 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" %)
Alexandr Fokin 7.13 4 |(% style="width:399px" %)(((
5 OperationCanceledException
6
7 [[Исключения | Exception >>doc:Разработка.NET.C#.Исключения | Exception .WebHome]]
Alexandr Fokin 7.14 8 )))|(% style="width:1094px" %){{code language="c#"}}// Когда идет остановка воркера, и нужно обработать OperationCanceledException без ошибки.
9 try
Alexandr Fokin 7.12 10 {
11 // action
12 }
13 catch(Exception ex)
14 {
15 if (
16 ex is OperationCanceledException oce
17 && oce.CancellationToken.Equals(cancellationToken)
18 )
19 {
Alexandr Fokin 7.14 20 //
Alexandr Fokin 7.12 21 }
22
23 // log
24 }{{/code}}
Alexandr Fokin 7.5 25 |(% style="width:399px" %){{code language="C#"}}Task.Yield(){{/code}}|(% style="width:1094px" %)(((
Alexandr Fokin 7.4 26 When would I use Task.Yield()?
Alexandr Fokin 7.3 27 [[https:~~/~~/stackoverflow.com/questions/22645024/when-would-i-use-task-yield>>https://stackoverflow.com/questions/22645024/when-would-i-use-task-yield]]
Alexandr Fokin 1.2 28
Alexandr Fokin 7.4 29 Async, recursion, and some weirdness in design of asynchronous API in C#
30 [[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]]
Alexandr Fokin 7.6 31
32 Настройка приостановки и возобновления с помощью Yield и ConfigureAwait
Alexandr Fokin 7.10 33 [[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]]
Alexandr Fokin 7.11 34
35 Task.Yield() in library needs ConfigureWait(false)
36 [[https:~~/~~/stackoverflow.com/questions/28309185/task-yield-in-library-needs-configurewaitfalse>>https://stackoverflow.com/questions/28309185/task-yield-in-library-needs-configurewaitfalse]]
Alexandr Fokin 7.4 37 )))
Alexandr Fokin 7.8 38 |(% style="width:399px" %)Задать размер стека для потока.|(% style="width:1094px" %)(((
39 Можно задать через параметр конструктора потока.
Alexandr Fokin 7.7 40 Можно использовать для удобного тестирования логики (например рекурсии), которая может вызвать переполнение.
Alexandr Fokin 7.4 41
Alexandr Fokin 7.8 42 RuntimeHelpers.TryEnsureSufficientExecutionStack Метод
43 [[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]]
Alexandr Fokin 7.9 44
45 Why is stack size in C# exactly 1 MB?
46 [[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]]
Alexandr Fokin 7.8 47 )))