AbandonedMutexException.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. //
  5. // AbandonedMutexException
  6. // Thrown when a wait completes because one or more mutexes was abandoned.
  7. // AbandonedMutexs indicate serious error in user code or machine state.
  8. ////////////////////////////////////////////////////////////////////////////////
  9. using System.Runtime.Serialization;
  10. namespace System.Threading
  11. {
  12. [Serializable]
  13. [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
  14. public class AbandonedMutexException : SystemException
  15. {
  16. private int _mutexIndex = -1;
  17. private Mutex? _mutex = null;
  18. public AbandonedMutexException()
  19. : base(SR.Threading_AbandonedMutexException)
  20. {
  21. HResult = HResults.COR_E_ABANDONEDMUTEX;
  22. }
  23. public AbandonedMutexException(string? message)
  24. : base(message)
  25. {
  26. HResult = HResults.COR_E_ABANDONEDMUTEX;
  27. }
  28. public AbandonedMutexException(string? message, Exception? inner)
  29. : base(message, inner)
  30. {
  31. HResult = HResults.COR_E_ABANDONEDMUTEX;
  32. }
  33. public AbandonedMutexException(int location, WaitHandle? handle)
  34. : base(SR.Threading_AbandonedMutexException)
  35. {
  36. HResult = HResults.COR_E_ABANDONEDMUTEX;
  37. SetupException(location, handle);
  38. }
  39. public AbandonedMutexException(string? message, int location, WaitHandle? handle)
  40. : base(message)
  41. {
  42. HResult = HResults.COR_E_ABANDONEDMUTEX;
  43. SetupException(location, handle);
  44. }
  45. public AbandonedMutexException(string? message, Exception? inner, int location, WaitHandle? handle)
  46. : base(message, inner)
  47. {
  48. HResult = HResults.COR_E_ABANDONEDMUTEX;
  49. SetupException(location, handle);
  50. }
  51. protected AbandonedMutexException(SerializationInfo info, StreamingContext context)
  52. : base(info, context)
  53. {
  54. }
  55. private void SetupException(int location, WaitHandle? handle)
  56. {
  57. _mutexIndex = location;
  58. _mutex = handle as Mutex;
  59. }
  60. public Mutex? Mutex => _mutex;
  61. public int MutexIndex => _mutexIndex;
  62. }
  63. }