I have few producers who will keeping filling into a BlockingCollection
with bounded capacity of 200. I am using Reactive Extensions and calling an async method below like this, and I wanted to know if this is the correct way of implementing it (will there be any performance / concurrency issue of using GetConsumingEnumerable
as every subscriber will get individual subscriber). I have used FromAsync
as to avoid calling async on subscriber based on other documentation on GitHub. userActivites
is a BlockingCollection
. This code runs on a background thread for ASP.NET Web REST API. FYI we are using BlockingCollection as being multi threaded we wanted to make sure that subscribe on order the way it receives the data and using FromAsync based on [Github](
https://github.com/dotnet/reactive/issues/459) issue.
IObservable<EventData> eventObservable = userActivites.
GetConsumingEnumerable().
ToObservable(TaskPoolScheduler.Default);
eventObservable.Select(number => Observable.FromAsync(async () =>
await SendDataToEventHubWithBatchAsync(number))).Concat().Subscribe();