Reputation: 470
I use multitasking a lot and I am working on adding Reactive Extensions into my set of tools. However I prefer to name threads so that I can better understand what threads are running when I break etc. In general it is just better. However I haven't found a good way to name threads when I am using reactive extensions with SubscribeOn and ObserveOn etc.
Any ideas?
Upvotes: 3
Views: 215
Reputation: 39202
If you are using the NewThreadScheduler
alot, you can make a subclass of it that customizes the Thread
it creates and then use your custom scheduler when using ObserveOn
or SubscribeOn
...
// created threads will have names prefixed with "bob"
someObservable.ObserveOn(new CustomNewThreadScheduler("bob"))...
Upvotes: 4
Reputation: 564461
When using Rx, most of the "threads" fall into three camps:
SubscribeOn
or ObserveOn
, which will be based on the framework's specified SynchronizationContext
. This is going to typically be the "main UI" thread if you're using a user interface, so naming the main thread will provide you the proper name.Since 2/3 of the options allow you to provide names, you could always name those threads, then assume any unnamed thread watched during debugging is a ThreadPool managed thread.
Upvotes: 1