.NET で関数を呼び出すときにタイムアウト値を設定することはできますか? 一連の Dropbox アカウントをループし、サーバー上の特定のフォルダーにコンテンツを取り込む SharpBox というサード パーティ コンポーネントを使用しています。
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 分後にあきらめることができるかどうか疑問に思っています。