Open AkazawaYun opened 3 months ago
or there is some other way to solve it ? i need a help, thank you ! the main purpose is to limit the concurrent worker count when many tcpclients receieve new msgs at the same time , so I wait the semaphore in each msg-process-callback. To avoid someone taked too long time (ex. do some await IOMethodAsync()) , before waiting an IO operation, the semaphore need to Release(), an when it completed, the semaphore need to Wait().
well, i solve it via putting the Task's awaiter and semephore as two fields into the CustomAwaiter , to effect the behavior of the CustomAwaiter's Constructure & OnComplet() method...
I'll try it too.
can you provide an public interface for "ValueTaskAwaiter" and "TaskAwaiter" please? they are both has IsCompleted { get; } and GetResult() . it's very inconvenient to define a custom XXXAwaiter for async/await without an interface like "IAwaiter",
there is an example:
i want to add some operation when await a Task, so i add an extend method to convert a Task to my CustomTask, in the CustomTask, there is an GetAwaiter() which return a CustomAwaiter. NOW, i met some problem :
In some case, i want the CustomTask.GetAwaiter() to directly return task.GetAwaiter(), it is an "TaskAwaiter" struct, And In some other case, i want to return new CustomAwaiter(), but i can't find the return-type to adapt the two type at the same time ! because there is not an INTERFACE to the TaskAwaiter.