混合托管/非托管C ++回调 [英] Mixing managed/unmanaged C++ callback

查看:80
本文介绍了混合托管/非托管C ++回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑如何在以下场景中混合托管/非托管C ++:


非托管

--------- ---

带有应该在托管中调用事件的方法的回调监听器类

Form1。

启动监听器的监听器的初始化代码线程。


管理

----------

带有自定义事件处理程序的Windows表单应用程序。


我相信这可以分为三个部分:


1)如何从非托管C ++调用Form1中的托管代码事件。

2)如何访问Form1(因为它是表单的实例)。

3)如何从Form1中初始化非托管回调侦听器。


谢谢!

I''m puzzled how to mix managed/unmanaged C++ in the following scenario:

Unmanaged
------------
Callback listener class with method that should call an event in managed
Form1.
Initialization code for the listener that launches the listener thread.

Managed
----------
Windows form application with a custom event handler.

I believe this can be broken down into three parts:

1) How to call the managed code event in Form1 from unmanaged C++.
2) How to access Form1 (since it is an instance of a Form).
3) How to initialize the unmanaged callback listener from within Form1.

Thanks!

推荐答案

>我很困惑如何在以下场景中混合托管/非托管C ++:
> I''m puzzled how to mix managed/unmanaged C++ in the following scenario:



我也想知道如何做到这一点。

几年前我试过这个,但到目前为止我从来没有能够做到这一点

工作。

我无法想象它不是以某种方式通过思考由Microsoft。


I am also wondering how to do this.
I tried this a few years ago but so far I have never been able to make it
work.
I cannot imagine that it is not somehow thought through by Microsoft.


>我很困惑如何在以下场景中混合托管/非托管C ++:
> I''m puzzled how to mix managed/unmanaged C++ in the following scenario:



我也想知道如何做到这一点。

几年前我试过这个,但到目前为止我从来没有能够做到这一点

工作。

我无法想象它不是以某种方式通过思考由Microsoft。


I am also wondering how to do this.
I tried this a few years ago but so far I have never been able to make it
work.
I cannot imagine that it is not somehow thought through by Microsoft.


我可以发送一个VS.NET解决方案,其中包含使用C#和C ++演示此项目的项目,



如果您有兴趣,请告诉我。


-Clift Norris

" DD"写道:
I could send you a VS.NET solution containing projects that demonstrate this,
using C# and C++.
Let me know if you are interested.

-Clift Norris
"DD" wrote:
我很困惑如何在以下场景中混合托管/非托管C ++:
I''m puzzled how to mix managed/unmanaged C++ in the following scenario:
我相信这可以分为三个部分:
I believe this can be broken down into three parts:


1)如何从非托管C ++调用Form1中的托管代码事件。
2)如何访问Form1(因为它是一个Form的实例)。
3)如何从Form1中初始化非托管回调侦听器。

谢谢!


1) How to call the managed code event in Form1 from unmanaged C++.
2) How to access Form1 (since it is an instance of a Form).
3) How to initialize the unmanaged callback listener from within Form1.

Thanks!



这篇关于混合托管/非托管C ++回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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