DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5

Thread: DoEvent

  1. #1
    Join Date
    Jul 2005
    Posts
    87

    DoEvent

    any one now how can i free DoEvent Stack (clear empty ..stop )
    i tray lackwindowsUpdate and me.visible=false its working but not 4 me



    let say im runing a loop for 1 day lol

    now i click on a button on the Form whan the loop is finsh
    it's run

    it's going to do the event mouse down ? that i did before

    or any events that i did ? how can i stop it from doing Events ?

    my project dont have any DoEvents()

    thanks
    Last edited by imosha; 12-03-2005 at 10:22 PM.

  2. #2
    Join Date
    Jul 2005
    Posts
    87
    Example

    Private sub Command1_Click()
    dim X as long
    for x=1 to 10000
    debug.print time
    next

    ''''((( free eventes )))
    end sub

    Private sub Command2_Click()
    debug.print "Click Whan the loop is runing"
    '''''((( i dont like that command 2 will work )))
    end sub

  3. #3
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I used DoEvents once, and I got so many problems that I never used it again.
    DoEvents works only with simple applications, but when there are thousands of events involved, DoEvents is useless because it flushes ALL of them.

    What I used instead of DoEvents is a state machine.
    When I have a long operation, I split it into smaller methods, or smaller loops. Then I keep a 'state' variable, that says in which state, or loop number, is my operation.
    At the beginning, I set this variable then I start a Timer. In the Timer event, I have a Select Case (in case of a state machine) or I just run one step of the loop, and at the end I restart the timer only if the next state is somethng like "done", or I do not have any more loops.

    For example:

    Code:
        private m_counter as long
        private m_bProgress as boolean
    
        command1_click()   '' start the timer
           m_counter = 0 
           m_progress = true
           timer1.enabled = true
        end sub
    
        timer1_OnTimer()   '' start the timer
           timer1.enabled = false
           if not m_bProgress then exit subn '' someone cancelled the operation
           '' do one loop only, one second time max
           m_counter = m_counter+1 
           timer1.enabled = (m_counter = NumberOfLoops)
        end sub
    Then, in all the events that deal with you operation, you need to change the value of m_counter, or of the operation in progress

    HTH
    Marco
    Last edited by mstraf; 12-05-2005 at 02:24 PM.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  4. #4
    Join Date
    Jul 2005
    Posts
    87

    Thumbs up

    next time i send u a private E-Mail : )

  5. #5
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote Originally Posted by imosha
    next time i send u a private E-Mail : )
    In the private area I answer only to private questions.
    Please post any technical question in the forum.


    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links