Outlook hangs on being being idle for 10 mins

R

ramz_g

Hi,
I have developed an add-in which is working fine except that there is one
rather big problem... Outlook freezes if I keep it idle for about 10 mins...
I read the following link "http://www.outlookcode.com/article.aspx?id=71"
about the add-in problem in Outlook.. But does this issue occur when
developing in C#? If so, how do I prevent Outlook from freezing? Can I have
some sample code to return to thread 0, in case that is what is required?

Thanks,
Ram
 
R

ramz_g

I would like to add that I'm using C# to develop Shared Add-in for Outlook
2003...

Thanks,
Ram
 
K

Ken Slovak - [MVP - Outlook]

What do you mean by "keep Outlook idle"?

Are you actually accessing the object model from a background thread? That's
what that article is describing.

There are 2 things to consider.

First if you are actually accessing the Outlook object model from a
background thread don't do that. Either move all of your accesses to the
main thread or synch your background threaded calls back to the main thread.

Second, if you are doing some process in the background that takes a very
long time and is monopolizing the processor cede some of that processor time
to other processes by calling System.Windows.Forms.Application.DoEvents()
every so often to allow the message pump to run.

For synching threads you need to pick up the main thread context. I usually
do that in code that handles NewInspector(), NewExplorer() and in something
like Explorer.SelectionChange() or Explorer.Activate() to ensure I get my
context. I then call DoEvents() to make sure the message pump is running and
pick up the thread context.

Then from a background thread I use the stored main thread context and synch
to that main thread context using a SendOrPostCallback() call.

That technique is also useful when doing things with WordMail windows from
managed code and with working with browser controls.
 
R

ramz_g

Hi Ken,

Thanks for your reply...

"keep Outlook idle" in the sense that I do some operations with my add-in in
Outlook and lock the computer (without closing outlook) and come back and
unlock it after, say, 10 mins to half an hour..

I am not accessing any Outlook Object Model from a background thread.. But I
in fact used the Threadstart delegate in a number of places and dint pool it
back to the caller thread (using Thread.Join())... I have included it in my
latest build and I think it might have solved the issue.. but I'm not sure
because the issue isn't consistent.. What do you reckon? Can starting a
thread and not notifying the caller about when it completes cause the problem
that I have mentioned, even if I dont access the object model from the
thread? Just curious...

Thanks,
Ram
 
K

Ken Slovak - [MVP - Outlook]

I'd think that might be a problem, but I'm not a threading expert. If it
solves the issue then you found the problem :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top