【发布时间】:2013-02-10 11:45:14
【问题描述】:
在.NET中调用函数时是否可以设置超时值?我正在使用一个名为 SharpBox 的第三方组件,它循环一组 Dropbox 帐户并将内容拉入我服务器上的给定文件夹。
Dim itemsDownload as integer = pollSingleDropboxAccount(accountID)
function pollSingleDropboxAccount(accountID as integer) as integer
//Utilises Sharpbox to download the files and return the count
//In here a connection is established using the SharpBox.dll
//but never gets closed or throws an exception leaving the
//function to hang indefinitely
end function
Sharpbox 在幕后使用 HTTPWebRequest 联系 Dropbox API,但似乎默认超时为无限,并且无法覆盖此值。我已经向 SharpBox 提出了功能请求,但我正在寻找我们可以同时使用的东西作为解决方法。
为了规避这个问题,我想知道我们是否可以在调用 'pollSingleDropboxAccount' 函数周围加上一些东西,以便在 5 分钟后放弃?
【问题讨论】:
-
你能使用 .NET 4.0+ 的 TPL 吗?
-
Implement C# Generic Timeout 的可能重复项
-
我们使用的是 .NET 4,所以是的,这是可行的。我现在正在图书馆查看更多细节
标签: .net function timeout dropbox sharpbox