- public class ThreadClass : IThreadRunnable\r
- {\r
- /// <summary>\r
- /// The instance of System.Threading.Thread\r
- /// </summary>\r
- private System.Threading.Thread threadField;\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the ThreadClass class\r
- /// </summary>\r
- public ThreadClass()\r
- {\r
- threadField = new System.Threading.Thread(new System.Threading.ThreadStart(Run));\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the Thread class.\r
- /// </summary>\r
- /// <param name="Name">The name of the thread</param>\r
- public ThreadClass(System.String Name)\r
- {\r
- threadField = new System.Threading.Thread(new System.Threading.ThreadStart(Run));\r
- this.Name = Name;\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the Thread class.\r
- /// </summary>\r
- /// <param name="Start">A ThreadStart delegate that references the methods to be invoked when this thread begins executing</param>\r
- public ThreadClass(System.Threading.ThreadStart Start)\r
- {\r
- threadField = new System.Threading.Thread(Start);\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the Thread class.\r
- /// </summary>\r
- /// <param name="Start">A ThreadStart delegate that references the methods to be invoked when this thread begins executing</param>\r
- /// <param name="Name">The name of the thread</param>\r
- public ThreadClass(System.Threading.ThreadStart Start, System.String Name)\r
- {\r
- threadField = new System.Threading.Thread(Start);\r
- this.Name = Name;\r
- }\r
- \r
- /// <summary>\r
- /// This method has no functionality unless the method is overridden\r
- /// </summary>\r
- public virtual void Run()\r
- {\r
- }\r
- \r
- /// <summary>\r
- /// Causes the operating system to change the state of the current thread instance to ThreadState.Running\r
- /// </summary>\r
- public virtual void Start()\r
- {\r
- threadField.Start();\r
- }\r
- \r
- ///// <summary>\r
- ///// Interrupts a thread that is in the WaitSleepJoin thread state\r
- ///// </summary>\r
- //public virtual void Interrupt()\r
- //{\r
- // threadField.Interrupt();\r
- //}\r
- \r
- /// <summary>\r
- /// Gets the current thread instance\r
- /// </summary>\r
- public System.Threading.Thread Instance\r
- {\r
- get\r
- {\r
- return threadField;\r
- }\r
- set\r
- {\r
- threadField = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets the name of the thread\r
- /// </summary>\r
- public System.String Name\r
- {\r
- get\r
- {\r
- return threadField.Name;\r
- }\r
- set\r
- {\r
- if (threadField.Name == null)\r
- threadField.Name = value; \r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets a value indicating the scheduling priority of a thread\r
- /// </summary>\r
- public System.Threading.ThreadPriority Priority\r
- {\r
- get\r
- {\r
- return threadField.Priority;\r
- }\r
- set\r
- {\r
- threadField.Priority = value;\r
- }\r
- }\r
- \r
- ///// <summary>\r
- ///// Gets a value indicating the execution status of the current thread\r
- ///// </summary>\r
- //public bool IsAlive\r
- //{\r
- // get\r
- // {\r
- // return threadField.IsAlive;\r
- // }\r
- //}\r
- \r
- /// <summary>\r
- /// Gets or sets a value indicating whether or not a thread is a background thread.\r
- /// </summary>\r
- public bool IsBackground\r
- {\r
- get\r
- {\r
- return threadField.IsBackground;\r
- } \r
- set\r
- {\r
- threadField.IsBackground = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Blocks the calling thread until a thread terminates\r
- /// </summary>\r
- public void Join()\r
- {\r
- threadField.Join();\r
- }\r
- \r
- /// <summary>\r
- /// Blocks the calling thread until a thread terminates or the specified time elapses\r
- /// </summary>\r
- /// <param name="MiliSeconds">Time of wait in milliseconds</param>\r
- public void Join(int MiliSeconds)\r
- {\r
- lock(this)\r
- {\r
- threadField.Join(MiliSeconds);\r
- }\r
- }\r
- \r
- ///// <summary>\r
- ///// Blocks the calling thread until a thread terminates or the specified time elapses\r
- ///// </summary>\r
- ///// <param name="MiliSeconds">Time of wait in milliseconds</param>\r
- ///// <param name="NanoSeconds">Time of wait in nanoseconds</param>\r
- //public void Join(long MiliSeconds, int NanoSeconds)\r
- //{\r
- // lock(this)\r
- // {\r
- // threadField.Join(new System.TimeSpan(MiliSeconds * 10000 + NanoSeconds * 100));\r
- // }\r
- //}\r
- \r
- ///// <summary>\r
- ///// Resumes a thread that has been suspended\r
- ///// </summary>\r
- //public void Resume()\r
- //{\r
- // threadField.Resume();\r
- //}\r
- \r
- /// <summary>\r
- /// Raises a ThreadAbortException in the thread on which it is invoked, \r
- /// to begin the process of terminating the thread. Calling this method \r
- /// usually terminates the thread\r
- /// </summary>\r
- public void Abort()\r
- {\r
- threadField.Abort();\r
- }\r
- \r
- /// <summary>\r
- /// Raises a ThreadAbortException in the thread on which it is invoked, \r
- /// to begin the process of terminating the thread while also providing\r
- /// exception information about the thread termination. \r
- /// Calling this method usually terminates the thread.\r
- /// </summary>\r
- /// <param name="stateInfo">An object that contains application-specific information, such as state, which can be used by the thread being aborted</param>\r
- public void Abort(System.Object stateInfo)\r
- {\r
- lock(this)\r
- {\r
- threadField.Abort(stateInfo);\r
- }\r
- }\r
- \r
- ///// <summary>\r
- ///// Suspends the thread, if the thread is already suspended it has no effect\r
- ///// </summary>\r
- //public void Suspend()\r
- //{\r
- // threadField.Suspend();\r
- //}\r
- \r
- /// <summary>\r
- /// Obtain a String that represents the current Object\r
- /// </summary>\r
- /// <returns>A String that represents the current Object</returns>\r
- public override System.String ToString()\r