Results 1 to 2 of 2

Thread: application hang problem

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2013

    application hang problem

    I have code below to check for piracy of my software. Though it is not the best out there but perhaps way to make it harder or annoying to be pirated.

    Public Sub CheckForPiracy(num As Long)
        Dim PauseTime, Start
        PauseTime = num   
        Start = Timer  
        Do While Timer < Start + PauseTime
            DoEvents   ' Yield to other processes.
        Call chknw   'This will check if the license is available, expired o correct.  If not, shutdown the 
        Dim i As Long
        i = RandomNumber(7200, 300) 
        CheckForPiracy(i)              'repeat the procedure
    End Sub
    I call the above procedure on mdiform form_activate event. But I notice that the toolbar on my mdiform hangs until I open up a new form where the whole app gui is refreshed.

    chknw procedure is an if statement checking the existence of license file, comparing license from license file and checking expiry date from license file. I dont think this causes application to hang.

    Can you advice me how I can optimize that code in order not to cause application hang.

    Last edited by codesearcher; Jun 10th, 2016 at 12:36 AM.

  2. #2
    Join Date
    Feb 2012
    West Virginia

    Re: application hang problem

    Why would you be having that sub call itself like that? You've got it checking over and over and over again.

    Anyway when an application hangs it is usually easy to tell where it is hanging. while running the program in the IDE select the IDE and hit the BREAK key. The program will stop and highlight the line that is currently being executed. 99% of the time there is your problem.

    I would expect that if that doesn't hang then it would give you memory or stack errors seeing as how you could have 1000s of instances of that sub after a while.

    It would make a lot more sense to get rid of that loop, get rid of any recursion and simply use a timer control.

    Then again it really doesn't make much sense to check for piracy over and over and over while the program is running. Its not like they can start a program and pirate it while it is running.

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