callbackClear.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. //
  6. //In theory this test could be race-y -- in which case suppress the console printing but in general ch should be well behaved
  7. //
  8. telemetryLog("Start Global Code", true);
  9. var foo1id = undefined;
  10. function foo1()
  11. {
  12. telemetryLog("Start Foo1", true);
  13. WScript.Echo("Hello World - CallBack 1");
  14. telemetryLog("End Foo1", true);
  15. }
  16. function foo2()
  17. {
  18. telemetryLog("Start Foo2", true);
  19. WScript.Echo("Cancel Callback 1 from CallBack 2");
  20. WScript.ClearTimeout(foo1id);
  21. telemetryLog("End Foo2", true);
  22. }
  23. foo1id = WScript.SetTimeout(foo1, 500);
  24. WScript.SetTimeout(foo2, 100);
  25. WScript.Echo("Hello World - Global");
  26. telemetryLog("End Global Code", true);