Reply

How to close SE document correctly

[ Edited ]

 

Hello!

I have just found the problem of closing SE documents. It doesn't matter if it's assembly or part. From my addin I'm just calling the method Close for a document and after that try to get active document. The result is the exception of SE. It happens not only after getting active document but also after calling other methods(but not every one).

It seems that calling the method Close doesn't close the document immediately. After closing I get all windows and among them I all the time find the window for that document.

I think I should give the time for SE after calling Close. I've wrote test. It works in the other process, after calling ?lose I wait for 1 second (Sleep(1000)) and it helps... But It's difficult to do in my application: It  is working in the same thread that SE is working. And It's not clear how long should I wait.

Probably someone know how to solve it. I've tried to Call pApplication->DoIdle() pApplication->IsIdling(1000) but nothing helps.

 

Thanks

 

Posted by: Sergey Sergeenko
Post date: 6/16/2010 12:02:53 AM

2 REPLIES

RE: How to close SE document correctly

[ Edited ]

So you have mutliple documents open (of which each has its own window), and you try to close one document, and want to get the new "ActiveDocument"?

 

If so, after closing one document, try to activate the window of the other document that you want to become the ActiveDocument. Then try to get the ActiveDocument again, it should work (I've had this problem too).

 

The thing is that closing down one document doesn't make one of the windows active, and somehow there's no activedocument.

 

Posted by: T. Jissink
Post date: 6/16/2010 1:05:40 AM

RE: How to close SE document correctly

[ Edited ]

Sorry for the delay..

Thanks for reply.

 

But what to do with the last document ?

The problem is not only in calling ActiveDocument.

After closing a document I also call other methods which show that the document is still in memory. For example the method pApplication->Windows. Among them sometimes I find a window for that closed document, sometimes - not.

 

So it seems that the document after calling Close is not closed immediately, but after a bit of time...

But anyway I will try to use your method

 

Thanks

 

Posted by: Sergey Sergeenko
Post date: 6/24/2010 3:58:11 AM