ConnectionManager.cs 792 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. namespace StressClient
  7. {
  8. public class ConnectionManager
  9. {
  10. // 线程列表
  11. List<Thread> _thread_list;
  12. public ConnectionManager()
  13. {
  14. _thread_list = new List<Thread>();
  15. }
  16. public void Add(Thread thread)
  17. {
  18. _thread_list.Add(thread);
  19. }
  20. public void Stop()
  21. {
  22. try
  23. {
  24. // 结束各线程
  25. foreach (Thread oneThread in _thread_list)
  26. {
  27. oneThread.Abort();
  28. }
  29. }
  30. catch (Exception)
  31. {
  32. // ignored
  33. }
  34. }
  35. }
  36. }