Can I put a thread on a mouse event handler?
Calls_Calls.MouseUp += new MouseEventHandler(Calls_Calls_MouseUp);
How to add a thread over this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would set up the event handler in the same way, but in the
Calls_Calls_MouseUpmethod you can launch a thread to do the work:However, I typically try to have my event handlers as unaware as possible, just calling some other method, often based on some condition:
This gives you the ability to trigger the exact same behavior from something else than the
MouseUpevent on a certain control (so that you can have the same behavior on a menu item, a toolbar button and perhaps a regular command button). It may also open up the possibility to have unit tests on the functionality (even though that is somewhat trickier with asynchronous code).