I have a C#/WPF application using WCL quite successfully. We found that WCL events are missed unless WCL runs in WPF's UI thread. Up to now this has meant we need to use System.Windows.Threading.DispatchTimer and not System.Timers.Timer.
We've just found an issue, where Bluetooth send and receive apparently blocks while the application is busy. We've already moved as much of the processing code into background threads as we can; what's left is the unavoidable WPF overhead for things like DataView updates.
The OPPThread sample works great (thanks!), but at its core it has an Application.DoEvents() loop. In its wisdom, Microsoft decided
DoEvents really *is* evil, and designed WPF without a DoEvents API.
Since WPF does all its UI handling on a single thread, it doesn't let you monitor Windows messages on a background thread. There are a few workarounds posted on the web, but they all come with scary warnings about bad effects and application instability.
So, my questions are:
- Is there a good way to use WCL in .NET without using a DoEvents() loop?
- Could this be causing the "Internal driver error" I reported in a different thread?