Exemple #1
0
		static void Main(string[] args)
		{
			UserData.RegisterType<ScriptSharedVars>();

			ScriptSharedVars sharedVars = new ScriptSharedVars();

			sharedVars["mystring"] = "let's go:";

			ManualResetEvent ev = new ManualResetEvent(false);

			StartScriptThread(sharedVars, "bum ", ev);
			StartScriptThread(sharedVars, "chack ", ev);

			ev.Set();

			Thread.Sleep(2000); // too bored to do proper synchronization at this time of the evening...

			Console.WriteLine("{0}", sharedVars["mystring"]);

			Console.ReadKey();
		}
Exemple #2
0
        static void Main(string[] args)
        {
            UserData.RegisterType <ScriptSharedVars>();

            ScriptSharedVars sharedVars = new ScriptSharedVars();

            sharedVars["mystring"] = "let's go:";

            ManualResetEvent ev = new ManualResetEvent(false);

            StartScriptThread(sharedVars, "bum ", ev);
            StartScriptThread(sharedVars, "chack ", ev);

            ev.Set();

            Thread.Sleep(2000);             // too bored to do proper synchronization at this time of the evening...

            Console.WriteLine("{0}", sharedVars["mystring"]);

            Console.ReadKey();
        }
Exemple #3
0
        private static void StartScriptThread(ScriptSharedVars sharedVars, string somestr, ManualResetEvent ev)
        {
            Thread T = new Thread((ThreadStart) delegate
            {
                string script = @"
				for i = 1, 1000 do
					shared.mystring = shared.mystring .. somestring;
				end
			"            ;

                Script S = new Script();

                S.Globals["shared"]     = sharedVars;
                S.Globals["somestring"] = somestr;

                ev.WaitOne();

                S.DoString(script);
            });

            T.IsBackground = true;
            T.Name         = "Lua script for " + somestr;
            T.Start();
        }
Exemple #4
0
		private static void StartScriptThread(ScriptSharedVars sharedVars, string somestr, ManualResetEvent ev)
		{
			Thread T = new Thread((ThreadStart)delegate
			{
				string script = @"
				for i = 1, 1000 do
					shared.mystring = shared.mystring .. somestring;
				end
			";

				Script S = new Script();

				S.Globals["shared"] = sharedVars;
				S.Globals["somestring"] = somestr;

				ev.WaitOne();

				S.DoString(script);
			});

			T.IsBackground = true;
			T.Name = "Lua script for " + somestr;
			T.Start();
		}