有没有办法让异步调用WCF误差反馈? [英] Is there a way to get error feedback on asynchronous WCF calls?

查看:146
本文介绍了有没有办法让异步调用WCF误差反馈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WCF服务,在同步(阻塞)模式下工作100%,我现在需要的,以便它使用异步模式返工的电话。

I have a WCF service which works 100% in the synchronous (blocking) mode and I now need to rework a call so that it uses the async pattern.

该服务使用的身份验证和执行从客户端分块的文件传输到服务器,所以我已经重新设计它使用开始异步preFIX揭开序幕呼叫。

The service uses authentication and performs a chunked file transfer from client to server so I have reworked it to use the 'Begin' async prefix to kick off the call.

现在我故意重整导致调用超时它试图传输的文件块,这需要不同年龄的各部分的用户凭据测试错误。问题是,我没有得到任何错误的反馈,看不出如何得到任何如果异步调用失败。这导致了一些非常大的文件未能在所有上传,但客户端是不知道它是没有异常抛出。

Now I'm testing for errors by deliberately mangling the user credentials which causes the call to timeout on each part of the file chunk it tries to transfer, which takes ages. The problem is that I don't get any error feedback and can't see how to get any if the async call fails. This leads to some very large files failing to upload at all, but the client being unaware of it as no exceptions are thrown.

我有调试 - >者除外>所有CLR例外打勾,看看是否有任何异常被吞噬,但仍然一无所获。

I have the Debug->Exceptions->All CLR exceptions ticked to see if there are any exceptions being swallowed but still nothing.

因此​​,在总结,你如何在WCF异步调用得到错误的反馈?

So in summary, how do you get error feedback from async calls in WCF?

由于提前,

瑞安

推荐答案

服务器为您缓存例外,如果你调用结束操作完成的方法为你的异步调用它会抛出所发生的任何异常。

The server caches the exception for you and if you call the end operation completion method for your async call it will throw any exceptions that occured.

private void go_Click(object sender, EventArgs e)
{
    client.BeginDoMyStuff(myValue, new AsyncCallback(OnEndDoMyStuff), null);
}

public void OnEndDoMyStuff(IAsyncResult asyncResult)
{
    this.Invoke(new MethodInvoker(delegate() { 
        // This will throw if we have had an error
        client.EndDoMyStuff(asyncResult);
    }));
}

这篇关于有没有办法让异步调用WCF误差反馈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆