| 123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.Net.Sockets;
- using Quadarax.Foundation.Core.Object;
- using Quadarax.Foundation.Core.Thread;
- namespace Quadarax.Foundation.Core.QMonitor
- {
- public class QMonWorkerContext : DisposableObject, IWorkerContext
- {
- #region *** Fields ***
- private UdpClient? _udpClient;
- #endregion
- #region *** Properties ***
- public UdpClient Client => _udpClient ?? throw new InvalidOperationException("UDP client channel is not open (is null).");
- #endregion
- #region *** Constructors ***
- public QMonWorkerContext(UdpClient? udpClient)
- {
- SetClient(udpClient);
- }
- #endregion
- #region *** Public Operations ***
- public void SetClient(UdpClient? udpClient)
- {
- _udpClient = udpClient;
- }
- #endregion
- #region *** Protected Operations ***
- protected override void OnDisposing()
- {
- Client?.Close();
- Client?.Dispose();
- SetClient(null);
- }
- #endregion
- }
- }
|