Results 1 to 3 of 3

Thread: [RESOLVED] [2008] System freeze while starting a loop for a couple of seconds.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    155

    Resolved [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!
    Last edited by shynet; Aug 30th, 2008 at 07:07 AM.

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    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.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    155

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width