View Single Post
  #6  
Old November 22nd 06, 02:49 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Unsubscribing from events (VSTO, C#)

Good.

The problem with the GC is that's it's non-deterministic. So you can release
something but the garbage collector might not get around to actually
releasing the references and cleaning things up for a while. In computer
code that seems like forever. Forcing collection releases things and gets
rid of those pesky event handlers.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message
oups.com...
Ken, thanks a lot, that was it! After adding

System.Runtime.InteropServices.Marshal.ReleaseComO bject(tasksItems);
tasksItems = null;
GC.Collect();


after unsubscription, Handler finally began no to catch delete event.
There was a problem when I also add GC.WaitForPendingFinalizers(); -
after executing this string outlook just stops responding, but without
it everything works just great.


Ads