f339f0c57472e7c8daf8961d33b6514cfd6f8d99.svn-base 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Collections;
  7. namespace IControls_FireManager
  8. {
  9. // 스레드 공용 루틴
  10. public static class _Thread
  11. {
  12. // 스레드 관리 해쉬테이블
  13. private static Hashtable CreatedThread = new Hashtable();
  14. // 생성 (파라미터가 없는 타입 : 스레드 실행시에 필요한 데이터가 없다)
  15. public static void Create(string Key, ThreadStart WorkFunction)
  16. {
  17. if (CreatedThread.Contains(Key) == true)
  18. {
  19. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.OverLapKey, 0);
  20. }
  21. else
  22. {
  23. // 스레드 생성
  24. Thread WorkingThread = new Thread(new ThreadStart(WorkFunction));
  25. // 스레드시작
  26. WorkingThread.Start();
  27. // 해쉬에 추가
  28. CreatedThread.Add(Key, WorkingThread);
  29. }
  30. }
  31. // 생성 (파라미터가 없는 타입 : 스레드 실행시에 필요한 데이터가 없다)
  32. public static void Create(string Key, ParameterizedThreadStart WorkFunction, object Data)
  33. {
  34. if (CreatedThread.Contains(Key) == true)
  35. {
  36. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, _Text.OverLapKey, 0);
  37. }
  38. else
  39. {
  40. // 스레드 생성
  41. Thread WorkingThread = new Thread(new ParameterizedThreadStart(WorkFunction));
  42. // 스레드시작
  43. WorkingThread.Start(Data);
  44. // 해쉬에 추가
  45. CreatedThread.Add(Key, WorkingThread);
  46. }
  47. }
  48. // 시작
  49. public static void Start(string Key)
  50. {
  51. if (CreatedThread.Contains(Key) == true)
  52. {
  53. ((Thread)CreatedThread[Key]).Start();
  54. }
  55. }
  56. // 종료
  57. public static void Abort(string Key)
  58. {
  59. if (CreatedThread.Contains(Key) == true)
  60. {
  61. ((Thread)CreatedThread[Key]).Abort();
  62. Delete(Key);
  63. _Event.DebugView_SendMessage_Write("스레드 중지!!!!");
  64. }
  65. }
  66. // 삭제
  67. public static void Delete(string Key)
  68. {
  69. if (CreatedThread.Contains(Key) == true)
  70. {
  71. CreatedThread.Remove(Key);
  72. }
  73. }
  74. }
  75. }