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