【发布时间】:2012-04-25 20:14:45
【问题描述】:
有时,如果我们的文件服务器很慢并且页面在超时之前没有完成,ASP.Net 会用 ThreadAbortException 对其进行处理。如果在 Win32Native.CreateFile 中发生这种情况,它会使文件句柄保持锁定状态,直到我们执行 iisreset。
这是 .NET 中的缺陷吗?我们能做些什么来解决这个糟糕的想法,比如将超时时间提高到某个巨大的数字......我认为 ThreadAbort.Reset 不会有帮助,因为损坏已经完成,我什至没有返回文件句柄从 FileStream 自己关闭它。
在 Microsoft.Win32.Win32Native.CreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)
在 Microsoft.Win32.Win32Native.SafeCreateFile(String lpFileName, Int32 dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, Int32 dwFlagsAndAttributes, IntPtr hTemplateFile)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode 模式)
【问题讨论】:
标签: .net multithreading exception-handling thread-safety resource-leak