简体   繁体   English

仅WCF异步操作

[英]WCF Async only operation

I have a client that use both async and sync method from a WCF service. 我有一个同时使用WCF服务的异步和同步方法的客户端。

I don't see any good reason to keep some sync call. 我看不出保持同步通话的任何正当理由。 Since I can with Task call async method within a sync one. 由于我可以用Task在一个同步内调用async方法。

And it's better to not block UI when I call my service. 并且最好在我调用服务时不阻止UI。

So I'm currently trying to remove every sync call. 因此,我目前正在尝试删除每个同步通话。 First is it a good pratice in WCF? 首先,在WCF中它是一个很好的实践吗? If not why? 如果不是,为什么?

And second I use svcutils to generate my files. 其次,我使用svcutils生成文件。 I have both sync and async call. 我同时有同步和异步电话。

The project is big and to remove sync call the easiest way is to generate only async call with svcutils. 该项目很大,要删除同步调用,最简单的方法是仅使用svcutils生成异步调用。 So with compile error I will be able to only keep async easily. 因此,由于编译错误,我将只能轻松保持异步。

But I can't find any option on svcutils that disable the sync method generation. 但是我在svcutils上找不到任何禁用同步方法生成的选项。

Any way to do so? 有办法吗?

In case if it is UI application it is better to use only async methods, as you said - to not block UI during calls. 如果是UI应用程序,最好只使用异步方法,如您所说-在调用过程中不要阻塞UI。

Regarding svcutil.exe, it can't create only async methods and ignore sync's. 关于svcutil.exe,它不能仅创建异步方法而忽略同步方法。 You can use /async parameter, but it will create all as async, which does not work for you. 您可以使用/ async参数,但它将全部创建为async,这对您不起作用。 Means, better to delete synchronous methods manually first. 最好先手动删除同步方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM