?
Solved

Active scripting: suspend &restart VB scripting?

Posted on 2000-03-01
5
Medium Priority
?
467 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 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 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