I’m really desperate. I have WPF MVVM app and I send and recieve some packets through USB. I use a library for that and this library needs HwndSource. Everything works fine, but now I need to send many packets and it takes some time so I decided that I use BackgroundWorker and show ProgressBar, but I don’t know how to use HwndSource in BackgroundWorker, because I got this error:
The calling thread must be STA, because many UI components require this.
Can anyone help me with this issue?
Thank you.
When using seperate threads they need to be in a STA (single-threaded apartment), which is not the case for background worker threads. You will probably have to create the thread yourself as stated in this answer
with
ThreadProcbeing adelegateof typeThreadStart.