0
我们有一个长时间运行的异步WCF服务操作,它从我们的服务中的不同组件抓取日志文件。现在,一切工作正常,但还有一个“我们想要实现的功能”。如何让WCF服务在超时后完成更多时间?
如果WCF将花费太长时间,它将超时异步服务,但如果我们的某个组件运行异常,则可能需要更长的时间才能发布其日志文件,而不是超时。如果发生这种情况,如果客户端应用程序告诉用户获取日志文件需要一段时间,并询问用户是否想继续等待,那将会很好。如果用户说是,有什么方法可以在超时时重启超时定时器的状态下恢复操作?
这个伪代码显示了我们心目中:
public void GetServiceLogFiles(Action<Object> callback)
{
try
{
var gotLogFilesDelegate = (result) =>
{ var answer = WcfService.EndGetLogFiles(result);
callback(answer); };
WcfService.BeginGetLogFiles(gotLogFilesDelegate, null);
}
catch(TimeoutException)
{
var dialog = new Dialog("The service is taking a while to get the log files. Would you like to keep on waiting for it to finish?");
if(dialog.response = Dialog.YES)
Magic_happens_here_and_lets_the_Wcf_Service_continue_working_on_Get_Log_Files();
}
}