In my WPF project I am trying to make the application icon on the taskbar blink using the following post: https://stackoverflow.com/questions/8924556/force-window-to-blink-when-a-particular- event-occurs-in-c-sharp-wpf
But when I call the method FlashApplicationWindow(); it sends me the following error
The calling thread cannot access this object because the owner is another thread.
Try sticking the call to FlashApplicationWindow(); inside BackgroundWorker but still throwing the same error.
Can someone help me how the call should be made please?
The usual thing is that an application works on the same thread all the time, but when you use multi-threading, either through BackgroundWorker, Task, Thread or others, new threads are created and those new threads cannot modify the main thread, which is the one that handles the user interface, that's why that message appears, because you try to do something with an element of the interface from a thread other than hers..
The classic solution to this problem can be summed up as putting your calls inside this:
And ready, with this you are telling the compiler to execute your instructions in the main thread, it is not necessary to put all the content of a method, just the part that has to do with the interface is enough.