Ejemplo n.º 1
0
        /// <summary>
        /// Queues a work item for processing on the managed thread pool
        /// </summary>
        /// <param name="callback">A WaitCallback representing the method to execute.</param>
        /// <returns>Reference to queued thread</returns>
        /// <remarks>
        /// This differs from the normal thread pool QueueUserWorkItem function in that it does
        /// not return a success value determing if item was queued, but rather a reference to
        /// to the managed thread that was actually placed on the queue.
        /// </remarks>
        public static ManagedThread QueueUserWorkItem(ThreadStart callback)
        {
            if (callback == null) throw (new ArgumentNullException("callback"));

            ManagedThread item = new ManagedThread(ThreadType.QueuedThread, callback, null, null);

            ManagedThreads.Queue(item);

            ThreadPool.QueueUserWorkItem(HandleItem);

            return item;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Queues a work item for processing on the managed thread pool
        /// </summary>
        /// <param name="callback">A WaitCallback representing the method to execute.</param>
        /// <param name="state">An object containing data to be used by the method.</param>
        /// <param name="ctx">Alternate execution context in which to run the thread.</param>
        /// <returns>Reference to queued thread</returns>
        /// <remarks>
        /// This differs from the normal thread pool QueueUserWorkItem function in that it does
        /// not return a success value determing if item was queued, but rather a reference to
        /// to the managed thread that was actually placed on the queue.
        /// </remarks>
        public static ManagedThread QueueUserWorkItem(ContextCallback callback, object state, ExecutionContext ctx)
        {
            if (callback == null) throw (new ArgumentNullException("callback"));

            ManagedThread item = new ManagedThread(ThreadType.QueuedThread, callback, state, ctx);

            ManagedThreads.Queue(item);

            ThreadPool.QueueUserWorkItem(HandleItem);

            return item;
        }
Ejemplo n.º 3
0
        internal void StartAsyncTransfer()
        {
#if ThreadTracking
            ManagedThread thread = new ManagedThread(TransferThreadProc);
            thread.Name = "PCS.Net.Ftp.FileTransferer.TransferThreadProc() [" + m_remoteFile + "]";
#else
            Thread thread = new Thread(TransferThreadProc);
            thread.Name = "Transfer file thread: " + m_remoteFile;
#endif
            thread.Start();
        }