关闭表单时,AxAcroPDF控制窗口表单会挂起 [英] AxAcroPDF control windows form hangs when closing the form

查看:97
本文介绍了关闭表单时,AxAcroPDF控制窗口表单会挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理用C#编写的Windows窗体.NET应用程序,该应用程序需要显示具有所有相关功能(旋转对象,更改灯光等)的3D pdf.我正在使用AxAcroPDF COM控件,它运行平稳.问题是,当我尝试关闭放置控件的窗体时,有时在放置控件时它会挂起几秒钟而没有明显原因.我在测试过程中加载的3D文件不是特别重.独立的Adobe Reader中的文件完全相同,打开和关闭没有特别的延迟. 我在Windows窗体关闭事件中使用以下代码:

I'm dealing with a windows forms .NET application written in C# which needs to display a 3D pdf with all the associated features (rotate the object, change lights and so on). I'm using the AxAcroPDF COM control and it run smoothly. The problem is that when I try to close the form where the control is placed, sometimes it hangs for several seconds with no apparent reason while disposing the control. The 3D file I loaded during the tests is not particulary heavy. The very same file in the standalone adobe reader opens and closes with no particular delay. I'm using the following code within the windows form closing event:

        private void DrawingForm_FormClosing(object sender, FormClosingEventArgs e)
        {
        this.axAcroPDF.Dispose();
        Application.DoEvents();
        CoFreeUnusedLibraries(); }

        [System.Runtime.InteropServices.DllImport("ole32.dll")]
        static extern void CoFreeUnusedLibraries();

有趣的是,如果仅显示文件,则窗体会正常关闭,但是,旋转3D文件中的对象时,窗体在关闭时会挂起.挂起时,将显示手表的图标(在独立的Adobe PDF中显示相同的图标).挂起时间在15到20秒之间. 我试图在webbrowser控件中显示文件,但得到了类似的结果.造成此问题的原因是什么? 我尝试搜索替代的稳定控件,但没有找到任何具有3D支持的控件.

The interesting thing is that the form closes normally if the file is just displayed, but, when the object within the 3D file is rotated, it hangs during closing. When it hangs, the icon of a watch (the same shown in standalone Adobe PDF) is displayed. The hanging time is between 15-20 seconds. I tried to display the file within the webbrowser control but I got similar results. What can be the cause of this problem? I tried to search for alternative stable controls but I haven't found any with 3D support.

推荐答案

FormClosing事件处理程序中,添加2行:

In FormClosing event handler add 2 lines:

this.Controls.Remove(yourAxAcroPDFControl);

yourAxAcroPDFControl = null; 在Adobe更新之前,将其视为临时解决方案.我检查了Adobe SDK示例,尽管它们是由Adobe自己编写的,但它们也引起了问题,因此我们可以期望他们认为这是一个问题.

yourAxAcroPDFControl = null; Consider it a temporary solution until Adobe has an update. I checked Adobe SDK samples and those cause problems too, despite being written by Adobe themselves so we could expect them to consider it a problem.

这篇关于关闭表单时,AxAcroPDF控制窗口表单会挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆