在.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 分钟后放弃?