Order of resetting MdiActiveDocument and calling CloseAndSave

Order of resetting MdiActiveDocument and calling CloseAndSave

Ertqwa
Advocate Advocate
339 Views
0 Replies
Message 1 of 1

Order of resetting MdiActiveDocument and calling CloseAndSave

Ertqwa
Advocate
Advocate

Hello Forum,

 

I use the following order of code (AutoCAD 2019, .NET, C#), which works fine, so I am hesitant to change anything:

 

docOriginal = DocumentManager.MdiActiveDocument;
...
using (Document docNew = DocumentCollectionExtension.Open(Application.DocumentManager, ..., false))
...
DocumentManager.MdiActiveDocument = docNew;
...
using (DocumentLock dlWorking = docNew.LockDocument())
{
// Do stuff.
{
...
docNew.CloseAndSave(...);
...
DocumentManager.MdiActiveDocument = docOriginal;

 

But would it make more sense to set "MdiActiveDocument " back to "docOriginal" BEFORE calling "docNew.CloseAndSave()"?

 

If anyone could explain a bit why this would be better (or not), or maybe does not matter at all, that would be great.

 

Thanks,

 

 

 

0 Likes
340 Views
0 Replies
Replies (0)