【问题标题】:Async methods on Sap .Net Connector 3Sap .Net 连接器 3 上的异步方法
【发布时间】:2015-01-09 01:11:07
【问题描述】:

我在我的 C# .Net v4.5 应用程序中使用 SAP .Net 连接器 3.0.0.42。到目前为止,我可以毫无问题地使用它:

var destination = RfcDestinationManager.GetDestination(destinationName);
var repository = destination.Repository;
var function = repository.CreateFunction(functionName);
function.Invoke(destination);
var resultTable = function.GetTable(tableName);  //This can be time consuming

有时,有些调用很耗时,因为它们是 IO 绑定操作,我想将其设为 async,因为在等待完成时不会阻塞线程,但 Sap .Net Connector 不会公开任何异步方法(据我所知)。

我读到了producing async/await methodsTask-based async pattern,但是要使用它,我需要低级别的async 方法来向上传播,对吗?例如,从Thread.Sleep 更改为Task.Delay。但是,如果没有这样的方法呢?

我的第一个想法是使用Task.Run,但我读到它用于 CPU 绑定操作,使用它会选择另一个线程并阻止它,所以它不是真正的async。另外,如果我开发一个 asp.net 应用程序会从池中获取另一个线程,不是吗?

所以,我的问题是是否可以将同步 IO 绑定方法包装在 async 中?我真的认为我在这里遗漏了一些东西......谢谢!

【问题讨论】:

    标签: c# asp.net .net asynchronous sap-dotnet-connector


    【解决方案1】:

    插件中似乎没有原生支持,但正如 Case Ahr here 所建议的,您可以在您的项目中进行。

    【讨论】:

      猜你喜欢
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-03
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 2023-03-18
      相关资源
      最近更新 更多