本文介绍了C#WaitCallBack - 线程池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是WaitCallback委托的确切目的?

What is the exact purpose of WaitCallback delegate ?

WaitCallback callback = new WaitCallback(PrintMessage);
ThreadPool.QueueUserWorkItem(callback,"Hello");

static void PrintMessage(object obj)
{
   Console.WriteLine(obj);
}

我可以的意思是等待中的TheadPool,直到线程是availabe.Once它可以执行目标?

Can i mean "Wait" in the "TheadPool" until thread is availabe.Once it is available executethe target?

推荐答案

在WaitCallback在这种情况下再presents一个指向将在从线程池中的线程执行的函数。如果没有线程可用它会等到一个得到释放。

The WaitCallback in this case represents a pointer to a function that will be executed on a thread from the thread pool. If no thread is available it will wait until one gets freed.

这篇关于C#WaitCallBack - 线程池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-16 02:19