简体   繁体   English

Win7上的VB.NET OpenFileDialog延迟

[英]VB.NET OpenFileDialog Latency on Win7

I have a winform, VBExpress 2008 with a single button and this code behind it to illustrate the problem: 我有一个winform,VBExpress 2008只有一个按钮,后面有这个代码来说明问题:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)  Handles Button1.Click
OpenFileDialog1.ShowDialog()
MsgBox(OpenFileDialog1.FileName)
End Sub

When I select a file (in my case small PDF's) I am getting a 3 to 6 second delay after selecting the file until it goes on to the next statement, in this case a MsgBox. 当我选择一个文件(在我的情况下是小PDF)时,我选择文件后会有3到6秒的延迟,直到它继续下一个语句,在这种情况下是一个MsgBox。

If I repeat selecting that same file a second time, I don't get the delay. 如果我第二次重复选择同一个文件,我不会得到延迟。 But, if I exit the program and re-start it, then I do get the delay again (one time). 但是,如果我退出程序并重新启动它,那么我会再次得到延迟(一次)。 After the first one hangs it looks like it hangs about ever 7 to 9 tries and the window says "not responding" for a few seconds. 在第一个挂起后,看起来它会挂起大约7到9次尝试并且窗口显示“没有响应”几秒钟。 I don't have this problem on Vista or XP. 我在Vista或XP上没有这个问题。

If I select the same file over and over, it might hang the 1st, 2nd and 12th time. 如果我反复选择同一个文件,它可能会挂起第1次,第2次和第12次。 Close program try same again, this might be the 1st, 3rd and 9th time. 关闭程序再试一次,这可能是第1次,第3次和第9次。 Never the same - as if it is running out of resources and clearing a cache. 从来没有 - 就像资源耗尽和清理缓存一样。

I've watched the task manager during the delay and don't see anything unusual coming up. 我在延迟期间看过任务经理,看不到任何不寻常的事情。 I have a new computer with everything operating properly. 我有一台新电脑,一切正常。 I thought maybe it was my Norton Internet Security -- but I turned that off and it made no difference. 我想也许这是我的诺顿网络安全 - 但我把它关闭了,它没有任何区别。

Can anyone give me a clue what might be going on and/or how I might trace the source of the delay to the bottom of it? 任何人都可以告诉我一些可能发生的事情和/或我如何追踪延迟的根源到底部? I've tried everything I know to isolate the problem and am running out of ideas. 我已经尝试了所有我知道的东西来隔离问题并且我的想法已经用完了。 I don't see any other posts about this particular thing. 我没有看到关于这个特定事物的任何其他帖子。

Project + Properties, Debug tab, tick "Enable unmanaged code debugging". Project + Properties,Debug选项卡,勾选“启用非托管代码调试”。 Run your program and select the Output window in VS. 运行程序并在VS中选择“输出”窗口。 Open your dialog. 打开对话框。 What you see in the Output window are a crapload of unmanaged DLLs getting loaded into your process. 您在“输出”窗口中看到的是一大堆非托管DLL,它们已加载到您的进程中。

These are the shell extension handlers that are installed on your machine. 这些是安装在您计算机上的shell扩展处理程序。 The bad ones can affect your program in unpleasant ways, much like you describe in your question. 坏的可能会以不愉快的方式影响您的程序,就像您在问题中描述的那样。 Use SysInternals' AutoRuns utility to get control over this. 使用SysInternals的AutoRuns实用程序来控制它。 Start by disabling the ones that were not made by Microsoft. 首先禁用那些不是由Microsoft制作的。

On MSDN suggestion was made to me -- remove network cable and see if problem disappears. 在MSDN上建议我 - 删除网络电缆,看看问题是否消失。 It did. 它做了。

I had two network connections to my old PC which was powered down. 我有两个网络连接到我的旧PC电源关闭。 Removed those and it resolved the problem. 删除了那些,它解决了问题。

So, now the question is in vb.net winforms, how do you customize the Win7 OpenFileDialog box (standard win explorer box) to not display or be delayed by dormant network locations? 所以,现在的问题是在vb.net winforms中,你如何自定义Win7 OpenFileDialog框(标准win资源管理器框)不显示或被休眠网络位置延迟? Or, how do you prevent this in Win7. 或者,你如何在Win7中防止这种情况。 I will research and if necessary re-post that separately. 我将研究并在必要时单独重新发布。

I really don't want to distribute my application with a warning that if you're on Win7 and have dormant network locations, you're going to get latency when choosing files. 我真的不想分发我的应用程序,并警告如果你在Win7上并且有休眠的网络位置,那么在选择文件时你会遇到延迟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM