C# Class ControlSystem.ThreadHandling

Class to handle all threads in system, everything handled by a unique description tag that stays with a thread from moment it gets added till it gets removed.
Show file Open project: syre/SortingIndustrialRobot

Public Methods

Method Description
ThreadHandling ( ) : System

Constructor for class : Makes a new list for usage

abortAllAndWait ( ) : void

Functions aborts all threads currently running and waits for them to finish

abortAndWait ( string _description ) : void

Terminates thread with supplied description, then waits for it to finish terminating

addThread ( ParameterizedThreadStart _parameterizedThreadStart, string _description ) : void

Overloaded addThread function, so that it can add threads with a parameterizedThreadStart to a thread list by a description

addThread ( ThreadStart _threadStart, string _description ) : void

addThread function, adds a function as a thread to a list, which needs its own thread for running. This specific function handles ThreadStart parameter, which means it can only take functions with no parameters as argument

find ( string _description ) : ThreadHolder

Function that looks up saved threads by description

removeThread ( string _description ) : void

Removes the specified thread from the thread list (Stops and waits for it to finish if it was running).

start ( string _description ) : void

Starts the thread from supplied description if found.

start ( string _description, object _obj ) : void

Starts the thread from supplied description if found but with a given parameter object

Private Methods

Method Description
remakeThread ( ThreadHolder _threadHolder ) : void

Remakes the thread so it can run under same name again.

Method Details

ThreadHandling() public method

Constructor for class : Makes a new list for usage
public ThreadHandling ( ) : System
return System

abortAllAndWait() public method

Functions aborts all threads currently running and waits for them to finish
public abortAllAndWait ( ) : void
return void

abortAndWait() public method

Terminates thread with supplied description, then waits for it to finish terminating
public abortAndWait ( string _description ) : void
_description string Description which the function needs to terminate thread for and wait for
return void

addThread() public method

Overloaded addThread function, so that it can add threads with a parameterizedThreadStart to a thread list by a description
public addThread ( ParameterizedThreadStart _parameterizedThreadStart, string _description ) : void
_parameterizedThreadStart ParameterizedThreadStart Parameter is name of function that needs its own thread, as its paramterizedThreadStart, it means it have to be a function with parameter object: (functionname(object example){})
_description string Description which the thread needs to be saved as (unique)
return void

addThread() public method

addThread function, adds a function as a thread to a list, which needs its own thread for running. This specific function handles ThreadStart parameter, which means it can only take functions with no parameters as argument
public addThread ( ThreadStart _threadStart, string _description ) : void
_threadStart ThreadStart Parameter is name of function that needs its own thread, as its Threadstart, it means it have to be a function with no parameters: (functionname(){})
_description string Description which the thread needs to be saved as (unique)
return void

find() public method

Function that looks up saved threads by description
public find ( string _description ) : ThreadHolder
_description string String that descripes the thread looking for
return ThreadHolder

removeThread() public method

Removes the specified thread from the thread list (Stops and waits for it to finish if it was running).
public removeThread ( string _description ) : void
_description string Description which the function need to find the thread that should be deleted
return void

start() public method

Starts the thread from supplied description if found.
public start ( string _description ) : void
_description string Description is a string which the function needs to search and find a thread for in a list
return void

start() public method

Starts the thread from supplied description if found but with a given parameter object
public start ( string _description, object _obj ) : void
_description string Description is a string which the function needs to search and find a thread for in a list
_obj object An object that needs to be passed on to the thread as start parameter
return void