Explorer.SelectionChange event triggered multiple times

  • Thread starter Thread starter Dorian
  • Start date Start date
D

Dorian

Sometimes when I change the selection in the explorer the SelectionChange
event gets triggered twice, other times it gets triggered once. I've been
able to fix it somewhat by filtering out when a MailItem is UnRead, but when
clicking through my read emails, I still get multiple triggers per MailItem.

I hookup the event in the addin Startup event and I've been breakpointing it
to make sure it only gets triggered once.

The functionality that I want is to trigger the event everytime a new
Explorer selection is made.
 
Why is this a problem? How and when the event fores depends on the kind of
folder, you are in, how the messages are selected, etc.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
It's a problem because everytime a message is selected I go through some very
time intensive tasks, and having it occurring twice tends to slow things
down. The messages are being selected in the Inbox folder. They are being
single selected by clicking on them with the cursor.
 
When the event fires up twice, do you get the same message both times (look
at MailItem.EntryID)?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
One other thing I've noticed. I added MessageBox.Show(item.EntryID) to check
the EntryID of my selected items. I couldn't for the life of me recreate the
problem. So I got rid of that and did a Debug.Print(item.EntryID) instead,
and I was able to recreate the problem again.
 
So here you go: store teh value of the last processed entry id and check to
see if the newly selected messgae is identical to the previous one. If yes,
do nothing.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
Taking the focus away the list to a message box woudl certainly change how
selection is processed, this is hardly surprising.

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