Replies: 3 comments
-
I don't know why this decision was originally made (having only taken control of the project fairly recently), so unless @bartdesmet happens to look in, we might not be able to get a definitive answer. However, I would guess it's because Going via an I try to avoid What are you doing that requires As for |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@idg10 Thanks for picking up on this.
Happens with both methods, the screenshot only shows threads left over by Delay because the ObserveOn calls have been caught and migitated in a previous iteration. (It's a ASP.NET Core application running a kestrel web service on Windows 10 LTSC, if that makes any difference) The usage of As @neuecc pointed out, If I put The Since it's not documented anywhere, this is a trap that many people might run into unknowingly, and it can result in weird application behavior which might vary on different platforms and is hard to debug (at least that happened to me). I suggest the following measures:
|
Beta Was this translation helpful? Give feedback.
-
Hi,
I've tripped over the so called "optimization" to schedule tasks as LongRunning by default multiple times now, especially since there is no documentation regarding this aspect of scheduling anywhere (or at least its not easy to find).
My most recent incident was a server application getting really slow after running for a week or two to the point where it would become unusable, which after taking a dotTrace snapshot shows it has apparently started lots of threads through the use of
Observable.Delay()
.I've already created a
ShortRunningTaskPoolScheduler
helper class which returns aTaskPoolScheduler.Default.DisableOptimizations(typeof(ISchedulerLongRunning)))
, which migitates the issue when I stuff it in every call toObserveOn()
orDelay()
.My intention behind using
ObserveOn()
can basically be described as "Get the subscribed work off the calling thread and just queue it into the task pool", rather than "The subscribed method runs veery long and therefore should use its own 'private' thread".I find it rather unintuitive that
ObserveOn()
andDelay()
don't actually use the threads in the ThreadPool, especially if I explicitely use aTaskPoolScheduler.Default
.Could anyone please explain the reasoning behind this behaviour?
Maybe I'm getting something totally wrong, but if not, please document this behavior i.e. on IntroToRx (which is an awesome resource by the way) so that people don't have to find out the hard way!
Beta Was this translation helpful? Give feedback.
All reactions