3

I referenced Acrobat.dll in a simple C# Console program, and then wrote a couple of lines of codes to run Acrobat.

CAcroApp mApp = new AcroAppClass();
Console.WriteLine("Acrobat is running");
bool bClose = mApp.CloseAllDocs();
bool bExit = mApp.Exit();

However, while CloseAllDocs() return true, Exit() always return false.

And accordingly I can still see Acrobat process running in the Task Manager.

However, once the program ends, the process also gets killed automatically.

How can I make it so that I can close Acrobat process from within the program without having to exit the program as well?

Sach
  • 10,091
  • 8
  • 47
  • 84

1 Answers1

0

From my experiance, the Acrobat process will close only when all related objects are garbage collected. To force collection, use the following code:

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

Note: Garbage collection only works when the related objects (e.g. mApp) are no longer in scope.

arni
  • 2,152
  • 19
  • 14