views:

207

answers:

2

Hi,

I am having some trouble keeping an event handle alive for some reason.

My project is an outlook addin which prompts the user to do something when they send an email. Now, I have an event handler hooked up to the Sent Items folder so that when the sent email arrives in that folder it fires the prompt. The reason I have it attached to the sent items folder is so that I can deal with the email after it is sent.

Initially all worked great and then I put it onto a client machine and the event didnt want to fire at all. This is when I attached another event (initially to figure what was happening) to the onSend event. What this does is call a singleton class which attaches the handle i require to the Sent Items folder so that the handle doesnt get re-created multiple times. (i did have it without a singleton class and instead had a global flag to switch when the handle was initially attached, but this was no different)

I hope this is all making sense!

What is happening now though is in some instances the first few emails will respond how they are supposed to; ie prompt after they have been sent. after this it stops to prompt and i cant figure out why.

I am hopeing that maybe there is a way I can check to see if the event handle exists directly. My only other thought is that maybe the handle i have setup is getting cleaned up somehow?

If anyone has any suggestions that help me figure what is going on i would greatly appreciate it.

+2  A: 

It is getting garage collected. If you post some of your code, I might be able to help.

+2  A: 

Classical garabe collection bug, try to keep reference in your code to the folder.