PeekCompletedEventArgs.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //------------------------------------------------------------------------------
  2. // <copyright file="PeekCompletedEventArgs.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. //------------------------------------------------------------------------------
  6. using System;
  7. namespace Experimental.System.Messaging
  8. {
  9. /// <include file='doc\PeekCompletedEventArgs.uex' path='docs/doc[@for="PeekCompletedEventArgs"]/*' />
  10. /// <devdoc>
  11. /// <para>Provides data for the <see cref='System.Messaging.MessageQueue.PeekCompleted'/> event. When your asynchronous
  12. /// operation calls an event handler, an instance of this class is passed to the
  13. /// handler.</para>
  14. /// </devdoc>
  15. public class PeekCompletedEventArgs : EventArgs
  16. {
  17. private IAsyncResult result;
  18. private Message message;
  19. private MessageQueue sender;
  20. /// <include file='doc\PeekCompletedEventArgs.uex' path='docs/doc[@for="PeekCompletedEventArgs.PeekCompletedEventArgs"]/*' />
  21. /// <internalonly/>
  22. internal PeekCompletedEventArgs(MessageQueue sender, IAsyncResult result)
  23. {
  24. this.result = result;
  25. this.sender = sender;
  26. }
  27. /// <include file='doc\PeekCompletedEventArgs.uex' path='docs/doc[@for="PeekCompletedEventArgs.AsyncResult"]/*' />
  28. /// <devdoc>
  29. /// <para>Contains the result of the asynchronous
  30. /// operation requested.</para>
  31. /// </devdoc>
  32. public IAsyncResult AsyncResult
  33. {
  34. get
  35. {
  36. return this.result;
  37. }
  38. set
  39. {
  40. this.result = value;
  41. }
  42. }
  43. /// <include file='doc\PeekCompletedEventArgs.uex' path='docs/doc[@for="PeekCompletedEventArgs.Message"]/*' />
  44. /// <devdoc>
  45. /// <para>The end result of the posted asynchronous peek
  46. /// operation.</para>
  47. /// </devdoc>
  48. public Message Message
  49. {
  50. get
  51. {
  52. if (this.message == null)
  53. {
  54. try
  55. {
  56. this.message = this.sender.EndPeek(result);
  57. }
  58. catch
  59. {
  60. throw;
  61. }
  62. }
  63. return this.message;
  64. }
  65. }
  66. }
  67. }