Souma Posted September 6, 2005 Posted September 6, 2005 I found one particular problem in ur implementation, it's not ur fault but the following codes: Dim t As DateTime t = Now.AddMilliseconds(150) Do Application.DoEvents() Loop While t > Now eats up 99% of my CPU, is there anyway to improvise it? The attachment come with it might be clearer for wat i'm doing.DeskPet_V0[1].1.zip Quote
Anthony_n Posted September 6, 2005 Posted September 6, 2005 without looking at your code can u would it not be better to do so somthing like this System.Threading.Thread.Sleep(10) Quote
Souma Posted September 6, 2005 Author Posted September 6, 2005 Any idea how to make my form always active regardless of what window i currenly viewing? E.g. Even if i'm viewing IE now, the form also can be seen and not send to back of the IE Quote
Diesel Posted September 6, 2005 Posted September 6, 2005 Set TopMost = true to keep on top and try System.Threading.Thread.CurrentThread.Sleep(10) instead of the loop Quote
Leaders snarfblam Posted September 11, 2005 Leaders Posted September 11, 2005 eats up 99% of my CPU' date=' is there anyway to improvise it?[/quote'] Yes, the dreaded DoEvents loop will send the taskmanager CPU reading to 99% and if you have a variable speed fan for your CPU you will hear it speed up, but as far as computer performance, that 99% of your CPU usage is your program throwing CPU control to Windows and saying "I don't want it!" and Windows throwing it back and saying "Well, I don't need it!" and back and forth and back and forth wasting CPU usage. But wait! There's Hope! When a program comes along and says "But I need the CPU!" Windows will throw CPU control to that program, and when that program is done with the CPU, your app and Windows go back to hot potato. In other, much simpler words, although CPU usage goes up, the CPU is still always available for other programs to use and the performance impact is much less than you might expect. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.