public void TestAnimations()
{
// construct AutoResetEvent for signaling 揌i Button?br> // Appearance on the form ev = new AutoResetEvent(false); button1.Enabled = true; // Set up asynchronous callback trigger using
// the AutoResetEvent and a 20 second timeout period ThreadPool.RegisterWaitForSingleObject(
ev,
new WaitOrTimerCallback(WaitThreadFunc),
"Hi",
20000,
false
);
// put each thread into the pool for running
// each animated gif. Pass the name of the gif
// file into the corresponding thread string[] GifFile = {"gif1.gif", "gif2.gif",
"gif3.gif"}; for (int i = 0; i < 3; i++)
{
ThreadPool.QueueUserWorkItem(new
WaitCallback(this.RunAnimation),
(object)GifFile[i]);
}
}
参考该例:http://www.c-sharpcorner.com/Code/2002/Nov/ThreadPoolGifs.asp
{
// construct AutoResetEvent for signaling 揌i Button?br> // Appearance on the form ev = new AutoResetEvent(false); button1.Enabled = true; // Set up asynchronous callback trigger using
// the AutoResetEvent and a 20 second timeout period ThreadPool.RegisterWaitForSingleObject(
ev,
new WaitOrTimerCallback(WaitThreadFunc),
"Hi",
20000,
false
);
// put each thread into the pool for running
// each animated gif. Pass the name of the gif
// file into the corresponding thread string[] GifFile = {"gif1.gif", "gif2.gif",
"gif3.gif"}; for (int i = 0; i < 3; i++)
{
ThreadPool.QueueUserWorkItem(new
WaitCallback(this.RunAnimation),
(object)GifFile[i]);
}
}
参考该例:http://www.c-sharpcorner.com/Code/2002/Nov/ThreadPoolGifs.asp
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货