如何调用另一个表单的Timer_Tick事件? [英] How to invoke Timer_Tick event of another form?

查看:109
本文介绍了如何调用另一个表单的Timer_Tick事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我有两种形式。我想调用第一种形式的Timer_Tick事件进入Form2的按钮点击事件。



提前谢谢

Hi
I have two forms. I want to invoke Timer_Tick event of first form into Form2''s button click event.

Thanks in advance

推荐答案

术语呼叫不适用于事件。可以调用一个事件,这是一个非常不同的事情:它调用添加到给定事件处理程序的调用列表中的所有事件处理程序。现在,即使从声明它的类开始,甚至从派生类中调用事件实例也是绝对不可能的。所以,你想要的是绝对不可能的。整个想法都错了。如果有可能,这将是一个危险的技术。



因此,我刚刚描述的限制使得事件实例与常规委托实例不同并禁止你想做什么,实际上是一件非常好的事情,它是一个非常简单的功能。你不应该试图克服它。



你永远不需要它。 (同样,这种限制是好事,也不错;它并不妨碍你做任何合理的事情。)你可能有一些真正的目标;实际上,如果没有这种滥用,这个目标很容易实现。你明白了吗?



如果没有,请说明你的目标是什么意思;我相信它会以文明的方式解决。



-SA
The term "call" is not applicable to events. An event can be invoked, which is a very different thing: it calls all the event handlers added to an invocation list of a given event handler. Now, even invocation of an event instance is absolutely impossible from anywhere except the class where it is declared, not even from a derived class. So, what you want is absolutely impossible. The whole idea is wrong. If it was possible, it would be a bad dangerous technique.

So, the limitation I just described which makes event instances different from "regular" delegate instance and which prohibits what you are trying to do, is actually a very good thing, one of its fool-proof features. You should not try to overcome it.

And you never really need it. (Again, this limitation is a good thing, not bad; it does not prevent you from doing anything reasonable.) You probably have some real goal; and in effect, this goal is easy to achieve without such abuse. Are you getting the idea?

If not, please explain what goal did you mean to achieve; I''m sure it will be solved in a civilized way.

—SA


这篇关于如何调用另一个表单的Timer_Tick事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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