Relative Content

Tag Archive for c#async-awaittasktaskcompletionsource

Using a TaskCompletionSource so a caller can asynchronously await for the next item

I have a class that processes a never ending stream of data. I also have external components that would like to asynchronously sample the processed data from time to time. Since it could be a while before the “next item” is processed, I’d like the data inspector components to “await” the item so they don’t block. They could be any number of different data inspecting components, and if multiple inspectors are awaiting an item, it’s fine if they all get the same item instance.