CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Pausing a program and doevents

    I just want a little help and clarification about making a program pause and wait for other processes to finish and using doevents. I want to program a loop that pauses to make sure that that all the pending events that are caused by the previous step in the same loop are finished before proceeding further. Specifically I have a loop that sends data using the winsock control and want to wait for the data to be finished transmitting before doing any other processing tasks. Any ideas would be greatly appreciated. I initially thought to use a do while loop with doevents like so:

    (...previous code in the for loop)
    do while boolean_var = true
    doevents
    loop
    (.. remaining code)



    and have the winsock control update boolean_var to false in a separate function when it's finished. My questions are, is this feasible (and optimal), and does doevents work for processes within the same program or does it apply to external processes that windows is running. Thank you,


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Pausing a program and doevents

    try this:


    dim sCount as integer

    '...some code, including the start of the for loop
    for t=1 to IDontKnowHowMuch
    winsock1.senddata "your data here"
    next t 'or whatever you used
    end sub

    private sub winsock1_sendcomplete(some parameters)

    'keeps track of how many times you have sent something, i case u need this
    'would be the value of t in the for loop
    sCount = sCount + 1
    doThingsToDo(sCount)

    end sub

    private sub doThingsToDo(tmpCount as integer)

    '...some code

    end sub




    Tom Cannaerts
    [email protected]

    The best way to escape a problem, is to solve it.
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Thanks! I'll try it out

    Thanks for your reply, what have seems good I'll try and implement it.


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

Featured