CompressedStack.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Runtime.Serialization;
  5. namespace System.Threading
  6. {
  7. public sealed class CompressedStack : ISerializable
  8. {
  9. private CompressedStack()
  10. {
  11. }
  12. public void GetObjectData(SerializationInfo info, StreamingContext context)
  13. {
  14. throw new PlatformNotSupportedException();
  15. }
  16. public static CompressedStack Capture()
  17. {
  18. return GetCompressedStack();
  19. }
  20. public CompressedStack CreateCopy()
  21. {
  22. return this;
  23. }
  24. public static CompressedStack GetCompressedStack()
  25. {
  26. return new CompressedStack();
  27. }
  28. public static void Run(CompressedStack compressedStack, ContextCallback callback, object state)
  29. {
  30. if (compressedStack == null)
  31. {
  32. throw new ArgumentNullException(nameof(compressedStack));
  33. }
  34. // The original code was not checking for a null callback and would throw NullReferenceException
  35. callback(state);
  36. }
  37. }
  38. }