了解C#活动使用发件人对象

了解C#活动使用发件人对象

本文介绍了了解C#活动使用发件人对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有理由新的C#作为一种语言(从C ++背景的)和我目前在编写的应用程序,使得使用事件驱动的API的过程。

I am reasonably new to C# as a language (coming from a C++ background) and I am currently in the process of writing an application that makes use of an event driven API.

这主要是由注册事件/响应处理程序和启动事件监视器,然后处理这些事件的异步/响应的。

Primarily this consists of registering event/response handlers and starting event monitors then dealing with these asychronous events/responses.

我有一个有点麻烦理解的事情是利用发送的对象。

The thing i'm having a bit of trouble understanding is the use of the sender object.

我想用它是到手柄传递给一个类对象我有各种结构和数据制作时的请求(或设置一个监视器)英寸然后在反应是收到/事件被提出我可以把发件人对象,将它转换回预期的类类型和访问成员,进行进一步的修改等,所以对待它,仿佛它只是仍然指向原始数据(这我希望会是谁?)。

What I would like to use it for is to pass a handle to a class object I have with various structures and data in when making a request (or setting up a monitor). And then on the response being recieved/the event being raised I can take the sender object, cast it back to the expected class type and access members, make further changes etc. so treating it as if it's just still a pointer to the original data (which I'm hoping it would be?).

所以我的问题确实是,因为我传递一个类的对象在我的要求下,将在得到有效的引用,或将它沿着价值线某处复制,因为它实际上只是一个普通的对象,我将结束与我的类对象上的事件的空复制?

So my question really is, as I am passing a class object in my request, will this be effectively a reference, or will it be copied somewhere along the line by value as it is actually just a generic object and I will end up with an empty copy of my class object on the event?

或第三个选项,我很可能完全错误的轨道上,并应该忘记整个事情? :)

Or the third option that i'm maybe completely on the wrong track here and should forget the whole thing? :)

问题是我的脑筋指针模式还是工作,我想......

Problem is my brains still working in pointers mode I think...

推荐答案

我不知道,我完全明白你的问题。但是,为了回答你的部分:

I don't know that I entirely understand your question. But to answer you in part:

您会得到一个关于你的对象。

You would get a reference to your object.

这篇关于了解C#活动使用发件人对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:16