Solved

Active scripting: suspend &restart VB scripting?

Posted on 2000-03-01
5
464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
gelbert earned 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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