View Single Post
  #4  
Old May 21st 10, 03:38 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Your server administrator has limited the number of items you

Yes, if you don't follow the advice you've seen from me and other posters
you are missing something. If you follow the advice you won't have those
problems.

Declaring the NewCont object outside the loop creates only 1 of those
objects. You just set it and reset it inside the loop. If you declare it
inside the loop and the loop executes 200 times you just created 200 of
those objects.

You can still do what you want, and then have to use
Marshal.ReleaseComObject() on each object plus setting each object to null,
then calling GC and WaitForPendingFinalizers on each pass through the loop.
That will also work, but the performance of loop execution will suffer a
lot. What I recommended is a balance of getting the loop to work and having
it work as fast as possible.

--
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


"spottedmahn" wrote in message
...
Hi Ken, thanks for the reply.

The point of the loop is to convert Outlook Contacts objects to My Custom
Contact Objects so it doesn't make sense to declare NewCont outside the
loop.
Maybe I'm mis-understanding you?

I've seen similar suggestions in other forum posts and it seems like a
cross
your fingers and hope solution which doesn't make me feel very
comfortable.

It seems like there should be a reliable way of "closing" objects that you
open. Am I missing something?

Thanks,
Mike D.


Ads