-
Notifications
You must be signed in to change notification settings - Fork 770
Description
Version: 4.1.0
Given this basic subscription
provider.Updates
.ObserveOn(TaskPoolScheduler.Default)
.Subscribe(PublishUpdate)
Having an issue where each time an item is pushed through the observable subject, we get new threads created for each subscriber, rather than being invoked on a thread pool thread.
As an example, if we have 10 clients connecting asking for updates which come from an IObservable
, we end up with 10 threads created to service each update that comes in. Given in our case we just want to make 10 WCF calls back over a client connection, this is a little heavy. Also with server mode GC the handle count is going to about 20,000+ in a handful of seconds before the GC finally kicks in.
This is due to the fact that the ScheduledObserver
will always using the TaskPoolScheduler
as ISchedulerLongRunning
, and then calling ISchedulerLongRunning.ScheduleLongRunning
, which results in a task with TaskCreationOptions.LongRunning
being set.
I cannot find a way to indicate to RX that the subscriber is not long running, and even though the scheduler supports long running, I really dont want it to happen.
To fix our issue I have made a copy of the TaskPoolScheduler
and removed the ISchedulerLongRunning
interface. Using this scheduler has flat-lined the handle count of the service.