Note that there are some explanatory texts on larger screens.

plurals
  1. POThreads are slow when audio is off
    primarykey
    data
    text
    <p>I have 2 projects. One is built by C++ Builder without MFC Style. And other one is VC++ MFC 11.</p> <p>When I create a thread and create a cycle -- let's say this cycle adds one to progressbar position -- from 1 to 100 by using <code>Sleep(10)</code> it works of course for both C++ Builder and C++ MFC.</p> <p>Now, <code>Sleep(10)</code> is wait 10 miliseconds. OK. But the problem is only if I have open media player, Winamp or anything else that produces "Sound". If I close all media player, winamp and other sound programs, my threads get slower than 10 miliseconds.</p> <p>It takes like <code>50-100 ms / each</code>. If I open any music, it works normally as I expected.</p> <p>I have no any idea why this is happening. I first thought that I made a mistake inside MFC App but why does C++ Builder also slow down?</p> <p>And yes, I am positively sure it is sound related because I even re-formated my windows, disabled everything. Lastly I discovered that sound issue.</p> <p>Does my code need something?</p> <p><strong>Update</strong>:</p> <p><s>Now, I follow the code and found that I used <code>Sleep(1)</code> in such areas to wait 1 miliseconds. The reason of this, I move an object from left to right. If I remove this sleep then the moving is not showing up because it is very fast. So, I should use <code>Sleep(1)</code>. With <code>Sleep(1)</code>, if audio is <strong>on</strong> than it works. If audio is <strong>off</strong> than it is very slow.</p> <pre><code>for (int i = 0; i &lt;= 500; i++) { theDialog-&gt;staticText-&gt;SetWindowsPosition(NULL, i, 20, 0, 0); Sleep(1); } </code></pre> <p>So, suggestions regarding this are really appreciated. What should I do?</p> <p>I know this is the incorrect way. I should use something else that is proper and valid. But what exactly? Which function or class help me to move static texts from one position to another smoothly?</p> <p>Also, changing the thread <strong>priority</strong> has not helped. </s></p> <p><strong>Update 2</strong>:</p> <p>Update 1 is an another question :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload