Loosing EventHandlers

  • Thread starter Thread starter Chris Walter
  • Start date Start date
C

Chris Walter

Hi,
I register the ItemAdd, ItemChange and ItemRemove Events
for my calendar,
<code>
Handles.TheLocalCalendar.Items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventH
andler(CalSync.Event_ItemAdd_im_lokalen_Kalender);
</code>
after a period of time the events won't fire no more.
Any idea what could cause this?

I tried to reassign the Eventhandler through a timer, but
if I only add a new Eventhandler, the Event fires more
than once.

When I first try to delete the current Eventhandler
<code>
Handles.TheLocalCalendar.Items.ItemAdd -= new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventH
andler (CalSync.Event_ItemAdd_im_lokalen_Kalender);
</code>
I get a NullReferenceException (even if I define an
object for the eventhandler).

Is there a way to determine if the Event is
still "alive", or is there another way to remove
eventhandlers from events?

TIA

Chris Walter
 
Make a variable that points to Items a global (class) variable:

m_Items = Handles.TheLocalCalendar.Items;
m_Items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(CalSync.Eve
nt_ItemAdd_im_lokalen_Kalender);


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top