我使用StackyClient库来遍历 Stack Overflow 中的最新问题。通常这有效:
StackyClient client = new StackyClient("1.1", "", Sites.MetaStackOverflow, new UrlClient(), new JsonProtocol());
var o = new QuestionOptions();
...
IPagedList<Question> l = null;
while (!stop) {
l = client.GetQuestions(o);
var newQuestions = (from Question q in l
orderby q.Id descending
select q).ToList();
...
}
但在某些时候,这似乎失败了。可能是由于网络连接问题或者我不知道是什么。程序挂在client.GetQuestions(o)
.
我想检测该问题并重新连接。我想过以某种方式设置超时以防止程序挂起。怎么做到呢?