Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / April 2007



Tip: Looking for answers? Try searching our database.

The program used up all the CPU resources

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 29 Apr 2007 22:49 GMT
I have developed an mail server software.  I have used the winsock to
control all the internet communication in the application.  When the
application runs to relay the outgoing emails, the application can run
properly.  But the problem is that it seems to used up the CPU resources.
All the buttons on the application panel cannot response to any action
anymore.  Just like hangup.

Can anyone advise me what is the problem?

Thanks,
Chris
Martin H. - 30 Apr 2007 00:01 GMT
Hello Chris,

In case you use a loop, you don't give any application (including
Windows) time to do anything. To prevent this use the DoEvents statement.

Best regards,

Martin

> I have developed an mail server software.  I have used the winsock to
> control all the internet communication in the application.  When the
[quoted text clipped - 7 lines]
> Thanks,
> Chris
Larry Serflaten - 30 Apr 2007 02:16 GMT
> I have developed an mail server software.  I have used the winsock to
> control all the internet communication in the application.  When the
[quoted text clipped - 4 lines]
>
> Can anyone advise me what is the problem?

You may not be yielding to allow the process to process its own messages.
Typically happens when the program is running a loop....

For an example try the following code in a new form, run it once to see
it runs as expected, then comment out the call to Yield and see that it
too can get so busy so as to become unrsponsive.

LFS

Option Explicit
Private Done As Boolean

Private Sub Command1_Click()
 Do While Not Done
   Debug.Print Timer
   Yield
 Loop
End Sub

Private Sub Yield()
Static Delay As Double
 If Abs(Timer - Delay) > 0.2 Then
   DoEvents
   Delay = Timer
 End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
 Done = True
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.