简体   繁体   English

使用计时器控制调用代表吗?

[英]Invoke Delegate with Timer Control?

I am using Invoke delegate with Timer Control and Thread Pool and i am worried about my Application Performance. 我正在将Invoke委托与Timer Control和Thread Pool一起使用,我担心我的应用程序性能。 So is there any other method apart from Timer. 因此,除了Timer之外,是否还有其他方法。

Also my windows application refreshes every 10 sec and memory size increases. 另外,我的Windows应用程序每10秒刷新一次,并且内存大小增加。 What should i do for that to restrict the memory. 我应该怎么做才能限制内存。

  1. Please provide more details for your problem. 请为您的问题提供更多详细信息。
  2. And memory size increases - This seems your application has memory leak issues.. And memory size increases -看来您的应用程序存在内存泄漏问题。
  3. Check that you are not creating new timer control, ie you need to reuse the same object instance for single purpose. 检查您是否没有创建新的计时器控件,即您需要将同一对象实例重用于一个用途。

Solution that I guess should help you by understanding your question; 我认为应该可以通过了解您的问题为您提供帮助的解决方案; Check for where you have coded such as 检查您编码的位置,例如

myInstanceControl.OnClick += new EventHandler(myInstanceControl_Click);

OR 要么

myInstanceControl.OnClick += myInstanceControl_Click;

If you have such code snippet in the module execute multiple times then there you need to also code to remove the event handler before object is unreferenced from the scope of execution or in the event handler itself. 如果模块中的代码片段多次执行,那么您还需要编写代码以删除事件处理程序,然后再从执行范围或事件处理程序本身中取消引用对象。 Such as

myInstanceControl.OnClick -= new EventHandler(myInstanceControl_Click);

OR 要么

myInstanceControl.OnClick -= myInstanceControl_Click;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM