So this is what I have now. I've changed all of the accessors for the event,
delegate and methods. I've created a new class that implements the EventArgs
class. I don't know where you were going with the args array thing, but in
all the examples I've seen, if you want to include custom data in an event
argument you implement Eventargs. I've gotten my example as close as I can to
yours and it's still coming back on a different thread. I am currently
calling a protected virtual method that in turn calls the delegate. Don't
worry, I'd be frustrated with me too :-)
// Main Class
public partial class ThisAddIn
{
private void Explorer_SelectionChange()
{
ReceivedMailHandler rmh = new ReceivedMailHandler();
// Do some stuff (Add data to the object)
rmh.SupportIgnoreChanged += new
ReceivedMailHandler. SupportIgnoreEventHandler(rmh_SupportIgnoreChanged );
Thread th = new Thread(rmh.ParseAndInsertReceivedMail);
th.IsBackground = true;
th.Start();
}
void rmh_SupportIgnoreChanged(Object sender,
ReceivedMailHandler.IgnoreEventArgs e) //Relates to your HelloUser
{
btnExpIgnore.Visible = e.visible; //Breakpoint here
}
}
// Worker Class
class ReceivedMailHandler
{
internal delegate void SupportIgnoreEventHandler(object Sender,
IgnoreEventArgs e); // Relates to your HelloUserDoneEventHandler
internal event SupportIgnoreDelegate SupportIgnoreChanged; // Relates to
your HelloUserDone
public void ParseAndInsertReceivedMail()
{
// Do work (no OOM objects)
RaiseIgnoreChange(new IgnoreEventArgs(true));
}
protected virtual void RaiseIgnoreChange(IgnoreEventArgs e) //Relates to
your OnHelloUserDone
{
SupportIgnoreEventHandler sid = SupportIgnoreChanged;
if (sid != null) sid(this, e);
}
public class IgnoreEventArgs : EventArgs
{
public bool visible;
public IgnoreEventArgs(bool Visible)
{
this.visible = Visible;
}
}
}
"Ken Slovak - [MVP - Outlook]" wrote:
You're not following the signature patterns of what I showed you, nor are
you calling to a protected virtual handler that in turns calls the delegate
event handlers.
You need to follow the signatures, where you will receive sender and an args
array in your delegate event handlers. To add a string like blah to the
event args you would create an args[] array and populate args[1] with blah.
You're trying to handle this like a normal raising event type thing and that
won't do what you want.
--
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