multithreading - .NET Threading Model and Application.DoEvents vs. Thread.Sleep -


We have a desktop application that sets a very strict set of calculations in the background thread, part of this calculation is an unmanaged library Which we use through the interop. What are we discovering that, when we remove the calculation, the UI thread becomes unresponsive for the duration of the calculation. We were under the impression that to handle the UI of the thread to allow the UI to respond. But it is not so. We have found that we can insert a thread. Sleep (0) or App Doants () to allow the UI to be responsive. It is a side effect to slow down this calculation. In addition, the fraction of the calculation executed by unmanaged code can take up to 30 seconds to complete, and during this time the application is always unresponsive

  • What is the relation between .NET Framework Threading Model?

    This leads to the following questions:

    • UI and interop?
    • Are we mistaken that the framework should handle thread switching between background and UI threads?
    • What is the difference between using Thread.Sleep and Application.DoEvents in this situation, and what is preferred over the other?
    • You can reduce the priority of your background thread, so it is preferred by the OS Will be done. You go to some domain knowledge that when you are prevented, you can go with Thread.Sleep to have control, so (0) surrender if your tiles are waiting for another thread.

      Application.DoEvents Pump windows message queue It will answer events like your app keystroke or window size. Thread Sleep Your Thread will premiered (or not, in case of threads sleep (0)).

      Also Read


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -