/// <summary> /// Initializes a new instance of the BackgroundThreadStartInfo class /// </summary> /// <param name="args">An array of arguments to pass to the thread when it starts</param> /// <param name="onRun"></param> public BackgroundThreadStartInfo(object stateObject, object[] args, BackgroundThreadStartEventHandler onRun, BackgroundThreadEventHandler onFinished) { //_allowThreadAbortExceptions = allowThreadAbortExceptions; _stateObject = stateObject; _args = args; _onRun = onRun; _onFinished = onFinished; }
/// <summary> /// Initializes a new instance of the BackgroundThreadStartInfo class /// </summary> /// <param name="args">An array of arguments to pass to the thread when it starts</param> /// <param name="onRun"></param> public BackgroundThreadStartInfo(bool allowThreadAbortExceptions, object stateObject, object[] args, BackgroundThreadStartEventHandler onRun, BackgroundThreadEventHandler onFinished) { _allowThreadAbortExceptions = allowThreadAbortExceptions; _stateObject = stateObject; _args = args; _onRun = onRun; _onFinished = onFinished; }
/// <summary> /// Initializes a new instance of the BackgroundThread class /// </summary> /// <param name="isBackground">A flag that indicates if the thread will be a background thread or not</param> /// <param name="args">An array of arguments to pass to the thread when it is started</param> /// <param name="onRun">A callback method that will be called when the thread runs</param> /// <param name="onFinished">A callback method that will be called when the thread finishes</param> public BackgroundThread(bool isBackground, object[] args, BackgroundThreadStartEventHandler onRun, BackgroundThreadEventHandler onFinished) { // the callback method is required now, if you waited until the thread starts, the thread will blow by the method // that calls the callback before you can wire up to it, so we have to have it now if (onRun == null) throw new ArgumentNullException("onRun", "A callback method is required."); // auto wire the callback to our event this.Run += onRun; // auto start the thread this.Start(isBackground, args); }
/// <summary> /// Initializes a new instance of the BackgroundThread class /// </summary> /// <param name="isBackground">A flag that indicates if the thread will be a background thread or not</param> /// <param name="args">An array of arguments to pass to the thread when it is started</param> /// <param name="onRun">A callback method that will be called when the thread runs</param> /// <param name="onFinished">A callback method that will be called when the thread finishes</param> public BackgroundThread(bool isBackground, object[] args, BackgroundThreadStartEventHandler onRun, BackgroundThreadEventHandler onFinished) { // the callback method is required now, if you waited until the thread starts, the thread will blow by the method // that calls the callback before you can wire up to it, so we have to have it now if (onRun == null) { throw new ArgumentNullException("onRun", "A callback method is required."); } // auto wire the callback to our event this.Run += onRun; // auto start the thread this.Start(isBackground, args); }
/// <summary> /// Initializes a new instance of the BackgroundThreadPoolJob class /// </summary> /// <param name="args">An array of objects passed to the thread when it is started</param> /// <param name="onRun">A callback method to be called by the thread</param> public BackgroundThreadPoolJob(string name, bool allowThreadAbortExceptions, object stateObject, object[] args, BackgroundThreadStartEventHandler onRun, BackgroundThreadEventHandler onFinished) : this(name, new BackgroundThreadStartInfo(allowThreadAbortExceptions, stateObject, args, onRun, onFinished)) { }
/// <summary> /// Initializes a new instance of the BackgroundThreadPoolJob class /// </summary> /// <param name="args">An array of objects passed to the thread when it is started</param> /// <param name="onRun">A callback method to be called by the thread</param> public BackgroundThreadPoolJob(string name, object stateObject, object[] args, BackgroundThreadStartEventHandler onRun, BackgroundThreadEventHandler onFinished) : this(name, new BackgroundThreadStartInfo(stateObject, args, onRun, onFinished)) { }