?
Solved

Active scripting: suspend &restart VB scripting?

Posted on 2000-03-01
5
Medium Priority
?
482 Views
Last Modified: 2013-11-20
We want to use VB scripting engine to drive our instrument. We have IActiveScript/IActiveParse, etc implemented and can run scripts which call our instrument's methods. BUT we need to suspend the script, wait for a message from our instrument and then restart the script from where it was suspended (not from the beginning. InterruptThread seems to just stop it completely. Is there any way of doing that?
Our scripting engine is housed in a out of process script server, our instrument, whose methods it runs is an .ocx run inside our main app. The app is written in MFC/C++.

And we are very confused...
0
Comment
Question by:Ewa
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
gelbert earned 1600 total points
ID: 2573348
Can you run script on separate thread?
Then you can use SuspendThread() & ResumeThread()
0
 
LVL 8

Expert Comment

by:gelbert
ID: 2573366
BTW There is IActiveScript::GetScriptThreadID() you just have to make sure that it is not the same thread as your main application
0
 
LVL 5

Expert Comment

by:vachooho
ID: 2575210
You can use IActiveScript::Clone() to get the cloned copy of current script state then IActiveScript::Close the first one
wait for a message from your instrument and then call SetScriptState(STATE_CONNECTED) to continue execution

Another solution

SetScriptState(SCRIPTSTATE_INITIALIZED) to suspend execution
SetScriptState(SCRIPTSTATE_CONNECTED) to continue execution

Hope this helps
 
0
 

Author Comment

by:Ewa
ID: 2575920
Thanks for many suggestions: I'm going to try some (some we have already, sort of tried - but maybe in a wrong context...)
 Vachooho, I think SetScriptState(SCRIPTSTATE_INITIALIZED) will stop the script OK, but then it will start from the beginning - I have to check that.

I think the first thing  I have to do is to add a Dispatch interface to script server, so its method (say SuspendScript) can be called from the script itself. Then our instrument, when ready, would call ResumeScript method on script server's (already existing)IScr interface...

Then I could try to make those methods
suspend and resume script's thread.
 So maybe gelbert's answer is the one - but still don't know.

Any way, thanks for being there - there might be the proverbial light at the end...

0
 

Author Comment

by:Ewa
ID: 2590909
Gelbert,

It certainly works, many thanks!!!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question