|
-
Feb 2nd, 2005, 11:44 AM
#1
Thread Starter
Fanatic Member
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:
MyControl.Start
Do While MyControl.Running
DoEvents
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:
MyControl.Start
'WAITING FOR RETURN FROM ACTIVEX ACTIONS
'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?
-
Feb 2nd, 2005, 02:27 PM
#2
Lively Member
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.
-
Feb 2nd, 2005, 02:30 PM
#3
Thread Starter
Fanatic Member
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:
And wait until
VB Code:
MyControl.Running = False
Hence my Do While loop. When
VB Code:
MyControl.Running = False
then I want to continue execution in the calling Event where I left off.
Hope that helps.
-
Feb 2nd, 2005, 04:07 PM
#4
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.
-
Feb 2nd, 2005, 04:17 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|