Solved

Active scripting: suspend &restart VB scripting?

Posted on 2000-03-01
5
430 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
method notes when mouse over in eclipse 5 86
ffmpeg - "rtsp://...... Operation not permitted" 4 80
scoreUp challenge 14 61
Excel file not created as expected 7 69
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

816 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

11 Experts available now in Live!

Get 1:1 Help Now