public void ProblemWithGlobalScope() { Script s = Script.Compile(@" abc = '123'; function OnGetCustomersCompleted(s, e) { s.v = abc; } s = new CustomerFacade(); s.GetCustomersCompleted += OnGetCustomersCompleted; s.GetCustomersAsync(); return s; "); CustomerFacade rez = (CustomerFacade)s.Execute(); while (rez.busy) { System.Threading.Thread.Sleep(100); } Assert.AreEqual("123", rez.v); }
public void ProblemWithGlobalScopeWithAsyncEvents() { CustomerFacade rez = (CustomerFacade)Script.RunCode(@" abc = '123'; function OnGetCustomersCompleted(s, e) { s.v = abc; } s = new CustomerFacade(); s.GetCustomersCompleted += OnGetCustomersCompleted; s.GetCustomersAsync(); return s; "); //Now scope is clear, while event is still subscribed and will be invoked while (rez.busy) { System.Threading.Thread.Sleep(100); } Assert.IsTrue(rez.v.Contains("given handler is not associated with any context")); }