![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
![]()
Ok, so here's what I do:
// Main Class public partial class ThisAddIn { private void Explorer_SelectionChange() { ReceivedMailHandler rmh = new ReceivedMailHandler(); // Do some stuff (Add data to the object) rmh.SupportExceptionThrown += new ReceivedMailHandler.SupportExceptionDelegate(rmh_S upportExceptionThrown); rmh.SupportIgnoreChanged += new ReceivedMailHandler.SupportIgnoreDelegate(rmh_Supp ortIgnoreChanged); Thread th = new Thread(rmh.ParseAndInsertReceivedMail); th.IsBackground = true; th.Start(); } void rmh_SupportIgnoreChanged(bool IsVisible) { btnExpIgnore.Visible = IsVisible; //Breakpoint here } void rmh_SupportExceptionThrown(Exception ex) { string blah = "asd"; //Breakpoint here } } // Worker Class class ReceivedMailHandler { public delegate void SupportExceptionDelegate(Exception ex); public delegate void SupportIgnoreDelegate(bool IsVisible); public void ParseAndInsertReceivedMail() { // Do work (no OOM objects) RaiseIgnoreChange(true); RaiseException(new Exception("blah")); } private void RaiseException(Exception ex) { SupportExceptionDelegate sed = SupportExceptionThrown; if (sed != null) sed(ex); } private void RaiseIgnoreChange(bool isVisible) { SupportIgnoreDelegate sid = SupportIgnoreChanged; if (sid != null) sid(isVisible); } } When it hits the breakpoints on rmh_SupportIgnoreChanged and rmh_SupportExceptionThrown, both are still in the worker thread. "Ken Slovak - [MVP - Outlook]" wrote: OnHelloUserDone() is a virtual method in the worker class. It calls to any event handlers that match the signature of the HelloUserDoneEventHandler delegate. Those handlers are in other classes and have registered to handle the event. If they do not match the signature or haven't registered for the event they won't get called. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Dorian" wrote in message ... That's exactly what I have, but when the event is fired, and I breakpoint the event code, visual studio shows it's still running in the worker thread. Is VS being a little misleading in it's thread monitoring? One thing I want to be clear about in your example: the OnHelloUserDone method is actually called on the worker thread, correct? |
Thread Tools | Search this Thread |
Display Modes | |
|
|