コード例 #1
0
ファイル: WSHBridge.cs プロジェクト: modulexcite/IL2JS
        public WSHBridge()
        {
            queueAvailable = new Semaphore(0, int.MaxValue);
            workAvailable = new Semaphore(0, int.MaxValue);
            resultAvailable = new Semaphore(0, int.MaxValue);
            plugin = new WSHPlugin(this);

            javaScriptThread = new Thread
                (() =>
                {
                    var instance = Activator.CreateInstance(typeof(Host.EcmaScript));
                    scriptEngine = (Host.IActiveScript)instance;
                    parser = (Host.IActiveScriptParse)instance;
                    var site = new WSHScriptSite(plugin);
                    HResult.ThrowOnFailure(scriptEngine.SetScriptSite(site));
                    HResult.ThrowOnFailure
                        (scriptEngine.AddNamedItem
                             (WSHScriptSite.GlobalPluginName, Host.ScriptItem.IsVisible | Host.ScriptItem.IsSource));
                    HResult.ThrowOnFailure(parser.InitNew());

                    queueAvailable.Release();
                    while (true)
                    {
                        workAvailable.WaitOne();
                        try
                        {
                            work();
                            result = null;
                        }
                        catch (Exception e)
                        {
                            result = e;
                        }
                        resultAvailable.Release();
                    }
                });
            javaScriptThread.Name = "Microsoft.LiveLabs.WSHInteropManager.WorkerThread";
            javaScriptThread.IsBackground = true;
            javaScriptThread.Start();
        }
コード例 #2
0
        public WSHBridge()
        {
            queueAvailable  = new Semaphore(0, int.MaxValue);
            workAvailable   = new Semaphore(0, int.MaxValue);
            resultAvailable = new Semaphore(0, int.MaxValue);
            plugin          = new WSHPlugin(this);

            javaScriptThread = new Thread
                                   (() =>
            {
                var instance = Activator.CreateInstance(typeof(Host.EcmaScript));
                scriptEngine = (Host.IActiveScript)instance;
                parser       = (Host.IActiveScriptParse)instance;
                var site     = new WSHScriptSite(plugin);
                HResult.ThrowOnFailure(scriptEngine.SetScriptSite(site));
                HResult.ThrowOnFailure
                    (scriptEngine.AddNamedItem
                        (WSHScriptSite.GlobalPluginName, Host.ScriptItem.IsVisible | Host.ScriptItem.IsSource));
                HResult.ThrowOnFailure(parser.InitNew());

                queueAvailable.Release();
                while (true)
                {
                    workAvailable.WaitOne();
                    try
                    {
                        work();
                        result = null;
                    }
                    catch (Exception e)
                    {
                        result = e;
                    }
                    resultAvailable.Release();
                }
            });
            javaScriptThread.Name         = "Microsoft.LiveLabs.WSHInteropManager.WorkerThread";
            javaScriptThread.IsBackground = true;
            javaScriptThread.Start();
        }
コード例 #3
0
 internal WSHScriptSite(WSHPlugin plugin)
 {
     WSHPlugin = plugin;
 }
コード例 #4
0
ファイル: WSHScriptSite.cs プロジェクト: modulexcite/IL2JS
 internal WSHScriptSite(WSHPlugin plugin)
 {
     WSHPlugin = plugin;
 }