I'm using a BackgroundWorker in C# and I need to change the thread's priority to RealTime and characteristics to "Pro Audio" using AvSetMmThreadCharacteristics.
Since the BackgroundWorker recycles threads in the ThreadPool, it's not adviced to change these kind of properties, but if I have to rewrite the code to use a normal Thread() instead, I loose all the extras (cancellation/progress/etc).
So, what problems can I expect when stick to a BackgroundWorker thread?
Just create a separate thread, you'll own it. A pool thread is intended for relatively short use, that doesn't seem to fit your case.
Reproducing the progress and cancellation logic isn't so difficult.
When you do change the properties inside a bgw, make sure you set them back (try/finally). But there are other issues, your Managed Pool thread might be switched when you lock or wait on something. At least the specs don't rule that out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With