C#应用程序到C ++的dll回到通过回调的C#应用​​程序 [英] C# app to C++ dll back to the C# app via callbacks

查看:106
本文介绍了C#应用程序到C ++的dll回到通过回调的C#应用​​程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个调用C ++ DLL C#应用程序。此DLL是成像系统的设备驱动程序;正在获取的图像时,图像的预览可以从上一行接一行的基础库。在C ++ DLL需要一个回调来填充在预览,并且该回调基本上由最终图象中,当前扫描线和数据本身的行的大小的

I'm writing a C# application that calls a C++ dll. This dll is a device driver for an imaging system; when the image is being acquired, a preview of the image is available from the library on a line-by-line basis. The C++ dll takes a callback to fill in the preview, and that callback consists basically of the size of the final image, the currently scanned line, and the line of data itself.

但问题是,有停止扫描和C#回调停止获取信息时,是从时间一个相当严重的延误。该方案的流程是这样的东西:

Problem is, there's a pretty serious delay from the time when scanning stops and the C# callback stops getting information. The flow of the program goes something like:


  1. 从C#中指定回调到C ++的dll

  2. 用户开始获取数据

  3. 设备启​​动

  4. DLL开始叫了几秒钟后回调(正常)

  5. 设备完成成像

  6. DLL仍在调用回调图像形成的两倍时间。

  1. Assign callback to C++ dll from within C#
  2. User starts to get data
  3. Device starts up
  4. dll starts to call the callback after a few seconds (normal)
  5. Device finishes image formation
  6. dll is still calling the callback for double the time of image formation.

这同一个DLL用C ++应用程序就好了工作;有没有出现是最后一步延迟。在C#中,但是,如果我有回调立即返回,延迟仍然存在;不管我的回调里面做的,它的存在。

This same dll worked with a C++ application just fine; there does not appear to be that last step delay. In C#, however, if I have the callback immediately return, the delay still exists; no matter what I do inside the callback, it's there.

这是延迟呼吁设法从非托管代码的代码固有的限制,或者是有什么任何一方可以做些什么来使这个走得更快?我是用C ++库作家接触,所以它可以实现从C ++侧修复

Is this delay an inherent limitation of calling managed code from unmanaged code, or is there something either side could do to make this go faster? I am in contact with the C++ library writer, so it's possible to implement a fix from the C++ side.

编辑:能不能做一些简单的就像一个命名管道的工作?可以从自己的管道中读取的应用程序?

Could doing something simple like a named pipe work? Could an application read from its own pipe?

推荐答案

原来的延迟是在C ++方面,由谁骂了开发商上下事实并非如此。

Turns out the delay is in the C++ side, by a developer who swore up and down it wasn't.

这篇关于C#应用程序到C ++的dll回到通过回调的C#应用​​程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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