I am building a method that uses the ManualResetEvent
but i can't get it to run after i initiate the WaitOne
method. Here is my code of the method. The code runs the code until it runs to the wait.WaitOne()
call. Thanks!!
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..");