473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application.Idl e, remove event handler?

I have a form class that acts as a top level window. The user can open
and close any number of these windows throughout the lifetime of the
application. In the OnLoad, I have:

Application.Idl e+=new EventHandler(Ap plication_Idle) ;

....and in the Dispose() override, I have:

Application.Idl e-=new EventHandler(Ap plication_Idle) ;

First question: Is the call in Dispose() necessary? I suspect it is. If
it weren't called, the Application object would continue to reference a
pointer to a disposed form. This wouldn't matter if the application were
about to shut down, but in a situation where the user continually opened and
closed these windows throughout the day/week, a memory leak would occur. Is
this correct?

I'm asking this because of a bug that's been in the WinForms framework
for sometime now. It occurs when an application closes. It only occurs in
debug mode. The symptom is as follows: The garbage collector thread crashes
with an unhandled exception (NullReferenceE xception). It turns out that
removing the idle event deregistration code in Dispose() fixes the error...
but it got me to wondering: Is it really necessary to perform this
deregistration at all?

Thanks...
Nov 22 '05 #1
2 3755
I can't anwser the other questions, but I would do this during the closing
of the Window if it was possible.

Etienne Boucher
Nov 22 '05 #2
I had the same thought. Moving the deregistration to OnClosing() or
prior to the Close() call yields the same bad result, however.

"Etienne Boucher" <et*****@novat. qc.ca> wrote in message
news:OL******** ******@TK2MSFTN GP10.phx.gbl...
I can't anwser the other questions, but I would do this during the closing
of the Window if it was possible.

Etienne Boucher

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
394
by: Chien Lau | last post by:
I have a form class that acts as a top level window. The user can open and close any number of these windows throughout the lifetime of the application. In the OnLoad, I have: Application.Idle+=new EventHandler(Application_Idle); ....and in the Dispose() override, I have: Application.Idle-=new EventHandler(Application_Idle);
1
1949
by: Weber Samuel | last post by:
Hi NG i try to catch the Application.Idle Event: --> Application.Idle += new EventHandler(OnIdle); Here's my problem: If i put a Label on my Form and set the Property AutoSize = true then the Eventhandler OnIdle never occurs! If the Property AutoSize is set to false the OnIdle - Handler will be called...
19
46685
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the inactivity of the system via GetLastInputInfo. That's not what I want - I want inactivity of the application. Thanks.
5
3127
by: Frank Rizzo | last post by:
Hello, I have a dozen 3rd party controls on my form. I am trying to detect when the application is idle. But even after the mouse and the keyboard are no longer moving, something is still triggering the Application.Idle event. There are no Timers on the form (i removed them all after realizing that WM_TIMER message will cause the event to fire). Anyway, how can I figure out which control is triggering the application_idle event? ...
5
2065
by: Leon | last post by:
Is there a way I can create a thread at application level that running all the time along with application exists? I have tried to do the above thing, and I found for some reason, the thread only can be excuted once after it is created. Thanks very much for your help.
20
4496
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
2
3693
by: sbcglobal | last post by:
Anyone knows how to add an Application.Idle handler in VB .Net Private WithEvents ?????????? As ???????? Public Sub IdleEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Application.Idle Application.DoEvents() End Sub
2
3048
by: Lucas Tam | last post by:
Without writing try/catch statements is there a way to have a global error handler in VB.NET? In ASP.NET there is an application level error handler inside Global.asax, but is there something similar for VB.NET winform programs? Thanks! -- Lucas Tam (REMOVEnntp@rogers.com) Please delete "REMOVE" from the e-mail address when replying.
1
5303
by: Rob | last post by:
How can I write the following code in VB.NET : private void Form1_Load(object sender, System.EventArgs e) { // Submit to Idle event to set controls state at idle time Application.Idle += new EventHandler(Application_Idle); } private void Application_Idle(object sender, EventArgs e) {
4
5816
by: Udi | last post by:
Hi All, What do you know about the Application.Idle event? When is it a good practice to use it and when should I not use it? I know it fires when the app message queue is empty, and that this happens a lot. But if I register many handlers on this event, what impact will it have on my application? Is it true to say that it doesn't impact my application performances becuase the queue is empty anyhow? Thanks!
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.