C
C#2y ago
CrosRoad95

❔ Batching actions

I have a technical question, let's say i have method that increment counter. The idea is that i would like to call this function multiple times and somehow detect what was the last change
inc();inc();inc(); - emit event notifying that counter = 3
inc();inc();inc(); - emit event notifying that counter = 3
right now i solved it by adding await Task.Delay that wait for few miliseconds, if new change arrive - cancel previous delay and begin delay again. if no new state change arrive - dispatch it anyone have a smarter solution?
2 Replies
ffmpeg -i me -f null -
if you are using Task.Delay this is async? so just to be clear inc() would be Task incAsync() then you say you want to "detect the last change", but say that you added a delay because you are waiting something... has not the inc method a CancellationToken as a parameter already?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.