Sharing context between scripts

21 views
Skip to first unread message

Andrei

unread,
Mar 31, 2011, 8:44:59 AM3/31/11
to SSharp
Hi Petro,

It's not clear to me if in the current implementation it's possible to
share a context between scripts.

ScriptContext global = new ScriptContext();
Script s1 = Script.Compile(c1);
s1.Context = global;

Script s2 = Script.Compile(c2);
s2.Context = global;

http://www.protsyk.com/scriptdotnet/wiki/index.php?title=Common_problems
shows it's possible.
but http://www.protsyk.com/scriptdotnet/wiki/index.php?title=Context
says it's not, which seems to be true.

Currently, my scenario is that I need to share a global context to
several scripts.
What I do is I create several script objects like this

Script s = Script.Compile(code);
s.Context = this.globalScriptContext;

All of them need to share a global context because I need to share
some objects.

Can you please give some hints to achieve this?

Thank you.




Petro Protsyk

unread,
Mar 31, 2011, 4:03:20 PM3/31/11
to ssh...@googlegroups.com
You can reuse context. But each Context could be owned by only one script at a time. I have updated first link, also you can look at ContextReusageProblem unit test

2011/3/31 Andrei <nite...@gmail.com>
Reply all
Reply to author
Forward
0 new messages