我正在构建一个使用的方法,但在我启动该方法ManualResetEvent
后我无法让它运行。WaitOne
这是我的方法代码。代码运行代码,直到它运行到wait.WaitOne()
调用。谢谢!!
var wait = new ManualResetEvent(false);
Color tmpColor = new Color();
MouseEventHandler tmpHandler = null;
ThreadPool.QueueUserWorkItem(delegate
{
Debug.WriteLine("Adding MouseEventHandler..");
tmpHandler = new MouseEventHandler(
(sender, e) =>
{
if (e.Button == MouseButtons.Left)
{
Bitmap tmpImage = new Bitmap(imgBox.Image);
tmpColor = tmpImage.GetPixel(e.X, e.Y);
Debug.WriteLine("Testing..");
}
else
{
Debug.WriteLine("Closing..");
this.Close();
}
wait.Set();
}
);
imgBox.MouseClick += tmpHandler;
});
Debug.WriteLine("Waiting..");
wait.WaitOne();
Debug.WriteLine("Running..");