Results 1 to 5 of 5

Thread: Wait for "process"!!

  1. #1

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    799

    Exclamation Wait for "process"!!

    I have an ActiveX Control that performs actions based on user interaction with it. The control enters a start "mode" when a certain case is found in the main application. The problem is, I want execution to pause or wait, until the ActiveX control has finished its actions.

    Currently the start mode call is in the middle of a HUGE code block with a lot of logic (in an Event). I am using the following to simulate what I want:

    VB Code:
    1. MyControl.Start
    2. Do While MyControl.Running
    3.      DoEvents
    4. Loop

    This works perfectly except that the processor is pegged due to the loop. I would like a way to simulate the following:

    VB Code:
    1. MyControl.Start
    2. 'WAITING FOR RETURN FROM ACTIVEX ACTIONS
    3.  
    4. 'COMPLETE, GO ON

    It is not an option to remove code following the call from the Event as it is part of the flow and has many variables set.

    Any ideas?

  2. #2
    Lively Member
    Join Date
    Jan 2005
    Posts
    76

    Re: Wait for "process"!!

    i am completely lost on your code, but it seems like your using a polling method and probably should be using a interupt driven method. i could be way off...and probably am.

  3. #3

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    799

    Re: Wait for "process"!!

    Ok, I have an ActiveX control I made called "MyControl." It has a method called "Start" and a property called "Running"

    In the middle of an Event I want to call:

    VB Code:
    1. MyControl.Start

    And wait until
    VB Code:
    1. MyControl.Running = False

    Hence my Do While loop. When
    VB Code:
    1. MyControl.Running = False
    then I want to continue execution in the calling Event where I left off.

    Hope that helps.

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Wait for "process"!!

    What does your activeX control do?
    if it doesn't launch any other threads or make calls to doevents, your main code should wait until your start procedure is finished.

    The only other way (and proper way) to handle this is to:
    1. add a finished event to the activeX control
    2. rewrite your main routine to run the completion code in the finished event.

    Enter the world of multitask programming and leave all these waiting loops behind.

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Wait for "process"!!

    go with moeur's suggestion to add an event to your control.... one thing to keep in mind is why your control is doing whatever it is that your control does... you need to disable things in your main app that you don't want the user to interface with while this control is working.. for example if there is a button that says start.. and when you click it it fires the MyControl.Start method, if you click it once and then click it again before the first time finished, this can cause obvious problems.. it is easy enough to plan for that, usually as simple enough as disabling controls you DON'T want the user to click while the process is running.. or even just disabling the entire form for the duration of the process.. then enable it when the finished even fires from your control...

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