SylTimeOut.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * ***************************************************************************
  3. *
  4. * 应用于一些操作超时请求的判断功能
  5. *
  6. * When applied to a network connection request timeouts
  7. *
  8. * **************************************************************************
  9. */
  10. using System;
  11. using System.Net.Sockets;
  12. namespace TFT_MelsecMcNet
  13. {
  14. /// <summary>
  15. /// 自定义 超时操作的类 [a class use to indicate the time-out of the connection]
  16. /// </summary>
  17. internal class SylTimeOut
  18. {
  19. /// <summary>
  20. /// 实例化对象
  21. /// </summary>
  22. public SylTimeOut()
  23. {
  24. StartTime = DateTime.Now;
  25. IsSuccessful = false;
  26. HybirdLock = new SimpleHybirdLock();
  27. }
  28. /// <summary>
  29. /// 操作的开始时间
  30. /// </summary>
  31. public DateTime StartTime { get; set; }
  32. /// <summary>
  33. /// 操作是否成功
  34. /// </summary>
  35. public bool IsSuccessful { get; set; }
  36. /// <summary>
  37. /// 延时的时间,单位毫秒
  38. /// </summary>
  39. public int DelayTime { get; set; }
  40. /// <summary>
  41. /// 连接超时用的Socket
  42. /// </summary>
  43. public TcpClient WorkSocket { get; set; }
  44. /// <summary>
  45. /// 用于超时执行的方法
  46. /// </summary>
  47. public Action Operator { get; set; }
  48. /// <summary>
  49. /// 当前对象判断的同步锁
  50. /// </summary>
  51. public SimpleHybirdLock HybirdLock { get; set; }
  52. }
  53. }