[RESOLVED] [2008] System freeze while starting a loop for a couple of seconds.
Hi guys !
I'm making an application with an API that detects the
mouse clicks (left, middle, and right).
I have this loop:
Code:
Public Sub BackLoop()
While Mode = True
My.Application.DoEvents()
If once = False Then
TempScript = SideCompare(Cursor.Position) 'Some Function
If TempScript <> Nothing Then
once = True
TempScript &= "|"
End If
Else
Dim x As String = SideCompare(Cursor.Position) 'Some Function
If x <> Nothing And Cursor.Position <> LastCoordinates Then
TempScript &= x & "|"
End If
End If
LastCoordinates = Cursor.Position
My.Application.DoEvents()
System.Threading.Thread.Sleep(5)
End While
End Sub
And again, no this is not a KEYLOGGER or anything close to that I don't support this kind of things.
So what my problem is that it works fine but I have this
code that turns the loop off and then turn in back on:
Code:
Private Sub MouseEvent(ByVal mEvent As Integer) Handles MHook.MouseEvent
If mEvent = &H208 Then 'Middle Mouse Up
Mode = False
My.Application.DoEvents()
Some code should be performed here
My.Application.DoEvents()
Mode = True
Call BackLoop()
End If
End Sub
this code make the loop go back on when the middle mouse button is up.
but the system freeze for a couple of seconds when this code is performed(the mouse can move but you can't do anything) when I removed these two lines:
Code:
Mode = True
Call BackLoop()
the system continued to work as it should (the loop starts when the application start and my system doesnt freeze when it start), but when I add these lines again
the system freeze for a couple of seconds.
But I can't remove these two lines because I need the loop to go back on ,
how can I make the loop go back without the freeze issues?
Thank you!
Re: [2008] System freeze while starting a loop for a couple of seconds.
why do you have so darn many doevents in there? i suspect that's most of the problem. doevents will eat up 100% system resources if you let it. Take the doevents out of the while loop.
Re: [2008] System freeze while starting a loop for a couple of seconds.
I think you might be right , I will try that...!
and I fixed the issue just by not turning of the first loop...
it's not such a fix but its still a solution for what I want.
Thank's again!