为何使用活动? [英] Why use Events?

查看:70
本文介绍了为何使用活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建自己的活动有什么理由?为什么不直接打电话给一个班级

方法/功能?


谢谢,

Brett

解决方案

因为必须显式调用方法或函数。当应用程序中的某些内容本身发生时,或者由于某个错误条件或触发的计时器事件而导致某种情况发生时,甚至会发生
。 。

另外,考虑一段控制另一段代码(B)的代码(A)。

B如何通知A发生了什么事。它没有概念

创造它,因此无法激发沟通。


" Brett" < no@spam.com>在消息中写道

新闻:我们************** @ TK2MSFTNGP09.phx.gbl ...

创建的理由是什么你自己的活动?为什么不直接调用一个类
方法/函数呢?

谢谢,
Brett



我通常会使用它们。


事件是为了暗示。


一个对象暗示某个事件的类。


你不能通过常规方法调用已经实例化的类的方法来自对象内的对象。

在这种情况下事件帮助和make生活轻松。


HTH

rawCoder


" Brett" < no@spam.com>在消息中写道

新闻:我们************** @ TK2MSFTNGP09.phx.gbl ...

创建的理由是什么你自己的活动?为什么不直接调用一个类
方法/函数呢?

谢谢,
Brett





" rawCoder" < RA ****** @ hotmail.com>在留言中写道

新闻:%2 *************** @ TK2MSFTNGP14.phx.gbl ...

我的方式通常使用它们。

事件是为了暗示。

一个Object为一些事件暗示一个类。

你不能通过常规手段调用一个方法已从对象内实例化对象的类。


你能在这里展示你的意思的代码示例吗?

事件在这种情况下有所帮助,让生活变得轻松。

HTH
rawCoder

Brett < no@spam.com>在消息中写道
新闻:我们************** @ TK2MSFTNGP09.phx.gbl ...

创建自己的活动有什么理由?为什么不直接调用一个类
方法/函数呢?

谢谢,
Brett




What are reasons to create your own events? Why not just call a class
method/function instead?

Thanks,
Brett

解决方案

Because a method or function has to be explicitly called. An even occurs
when something within the application happens by itself, or as a result of
something, like an error condition, or a timer event being fired. .
Also, consider a piece of code (A) that controls another piece of code(B).
How would B notify A that something has happened. It has no concept of what
has created it, and therefore cannot instigate the communication.

"Brett" <no@spam.com> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...

What are reasons to create your own events? Why not just call a class
method/function instead?

Thanks,
Brett



The way I use them ususally.

Events are for intimation.

An Object intimating a class for some event.

You cant by regular means call a method of the class that has instantiated
the object from within the object.
Events help in this case and make life easy.

HTH
rawCoder

"Brett" <no@spam.com> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...

What are reasons to create your own events? Why not just call a class
method/function instead?

Thanks,
Brett




"rawCoder" <ra******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...

The way I use them ususally.

Events are for intimation.

An Object intimating a class for some event.

You cant by regular means call a method of the class that has instantiated
the object from within the object.
Can you show a code example of what you mean here?
Events help in this case and make life easy.

HTH
rawCoder

"Brett" <no@spam.com> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...

What are reasons to create your own events? Why not just call a class
method/function instead?

Thanks,
Brett




这篇关于为何使用活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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