Form closing slow because of PDF viewer

966 Views Asked by At

We have a Winforms application that uses PDFViewer and AxAcroPDFlib. We previously had a problem where the form would hang when closing because the pdf control was having trouble closing. The solution, found here, was to assign focus to a different control during the forms closing event. This has worked with no problems since implementing.

This past week there was an update to Adobe Reader DC and the problem seems to have returned. There is a delay in closing the form again. When closing the form an Adobe Acrobat icon appears on the task bar for about 10 seconds, then disappears and the form closes. This is what happened before.

Does anyone have any idea how to correct this problem now?

I'd like to replace this control with another that doesn't rely on the user having Acrobat installed but until I have the time to do that I need a fix/workaround.

3

There are 3 best solutions below

0
On BEST ANSWER

There was no delay in my application this morning. I checked Programs and Features and found that Acrobat Reader has been updated to version 15.023.20070. It looks like Adobe has fixed the bug. I'm not seeing the delay any more.

If you've been having this problem, check to see if the update fixes it for you. In the last couple weeks I saw several workarounds that others said were working for them that did not work for me so it's possible my problem was not the same as others so this update may not fix everyone's problem. It appears to have fixed mine though.

1
On

I got the same problem.

Removing AxAcroPDF control from form's control collection when closing works for me.

A

1
On

After trying many of the solutions I have found during the last 8 hours of trying to solve this problem I have finally found this as a solution.

During the FormClosing event add the following

  • Use the loadFile routine to load a PDF that doesn't exist
  • Change the focus to some other object
  • Let other events fire
  • Sleep for 50

See my C# code below. If I remove any one of these lines the hang on form close reappears.

if (this.axPDF != null)
{
    axPDF.LoadFile("someFileThatDoesntExist.PDF");
    cmdNext.Focus();
    System.Windows.Forms.Application.DoEvents();
    System.Threading.Thread.Sleep(50);
    axPDF.Dispose();
}