Solved

Active scripting: suspend &restart VB scripting?

Posted on 2000-03-01
5
408 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 400 total points
Comment Utility
Can you run script on separate thread?
Then you can use SuspendThread() & ResumeThread()
0
 
LVL 8

Expert Comment

by:gelbert
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Gelbert,

It certainly works, many thanks!!!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now