コード例 #1
0
ファイル: ThreadRunner.cs プロジェクト: koma00/GatewayIrbis
        /// <summary>
        ///
        /// </summary>
        /// <param name="method"></param>
        /// <param name="parameters"></param>
        public static void AddToPool
        (
            ThreadMethod method,
            params object[] parameters)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            ThreadRunner runner = new ThreadRunner();

            runner._method     = method;
            runner._parameters = parameters;
            ThreadPool.QueueUserWorkItem(runner._MethodCallback);
        }
コード例 #2
0
ファイル: ThreadRunner.cs プロジェクト: koma00/GatewayIrbis
        /// <summary>
        ///
        /// </summary>
        /// <param name="method"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static Thread RunThread
        (
            Delegate method,
            params object[] parameters)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            ThreadRunner runner = new ThreadRunner();

            runner._delegate   = method;
            runner._parameters = parameters;
            ThreadStart start  = new ThreadStart(runner._RunDelegate);
            Thread      result = new Thread(start);

            result.IsBackground = true;
            result.Start(parameters);
            return(result);
        }