473,503 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MDI - disposing of child windows after a period of inavtivity

Hi
I have an MDI app....
All child MDI windows are non-updateable... however, the users may leave the
windows open... and there can be several of them.

I want to implement a system to dispose of MDI child windows after a period
of inactivity, in order to release resources and fire a garbage collect...

Does anyone have any views, or ideas on how to do this??

Thanks
Nov 16 '05 #1
3 1797
You can use Deactivate event of the Child Form with a timer.

private void ChildForm_Deactivate(object sender, System.EventArgs e)

{

Timer t = new Timer();

t.Tick +=new EventHandler(t_Tick);

t.Interval = 2000; // for two seconds

t.Start();

}
protected void t_Tick(object sender , EventArgs e)

{

this.Dispose();

}

Hope this Helps
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:eX******************@fe1.news.blueyonder.co.u k...
Hi
I have an MDI app....
All child MDI windows are non-updateable... however, the users may leave the windows open... and there can be several of them.

I want to implement a system to dispose of MDI child windows after a period of inactivity, in order to release resources and fire a garbage collect...

Does anyone have any views, or ideas on how to do this??

Thanks

Nov 16 '05 #2
Paul,

You would create the forms so that each form would have a timer that
would fire when the time expires. Every time you do an action on the form,
you would reset the timer and change the time elapsed (you would disable the
timer, then restart it).

Basically, when the timer fires, you would call Dispose on the form (the
timer will only fire when no action has taken place). This will take care
of the unmanaged resources the form was holding.

It might actually be a good idea to call GC.Collect. I used to think
that you should not call GC.Collect except in the most rare of cases, but it
appears that your situation is prime for calling a Collect. Check out Rico
Mariani's blog entry on the subject, located at (watch for line wrap):

http://blogs.msdn.com/ricom/archive/...29/271829.aspx

However, I would still generally say that you should not call GC.Collect
generally, unless your performance tests indicate you have a bottleneck
under the conditions specified in the blog entry.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:eX******************@fe1.news.blueyonder.co.u k...
Hi
I have an MDI app....
All child MDI windows are non-updateable... however, the users may leave
the windows open... and there can be several of them.

I want to implement a system to dispose of MDI child windows after a
period of inactivity, in order to release resources and fire a garbage
collect...

Does anyone have any views, or ideas on how to do this??

Thanks

Nov 16 '05 #3
Thanks for the replies,

How can I tell if the form is the 'active' MDI child??
I don't want to shut the window, if it is the active MDI child...

Thanks

"SerhaD Ýnanlý" <se**********@hotmail.com> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
You can use Deactivate event of the Child Form with a timer.

private void ChildForm_Deactivate(object sender, System.EventArgs e)

{

Timer t = new Timer();

t.Tick +=new EventHandler(t_Tick);

t.Interval = 2000; // for two seconds

t.Start();

}
protected void t_Tick(object sender , EventArgs e)

{

this.Dispose();

}

Hope this Helps
"Paul Aspinall" <pa**@aspy.co.uk> wrote in message
news:eX******************@fe1.news.blueyonder.co.u k...
Hi
I have an MDI app....
All child MDI windows are non-updateable... however, the users may leave

the
windows open... and there can be several of them.

I want to implement a system to dispose of MDI child windows after a

period
of inactivity, in order to release resources and fire a garbage
collect...

Does anyone have any views, or ideas on how to do this??

Thanks


Nov 16 '05 #4

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

Similar topics

10
6471
by: Patrick De Ridder | last post by:
I have been looking at an example, and there is something I don't inderstand. Given: form1 calls form2 --------- Question: What is the use of having these lines in form2 --------------...
8
4917
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
2
11824
by: CJack | last post by:
Hy. I have an MDI form Parent. on run-time it creates a child form Child1. when you press a keyboard button, the Control on Child1 recieves the KeyUp event, which raises the KeyUp event of Child1...
4
2225
by: Dakkar | last post by:
I have a program with windows forms and after execution of my program im making it invisible for working background progress and i have a dispose function like this protected override void...
4
2009
by: Bonj | last post by:
Further to my last post, I have managed to get a child window to display. But its messages are routed to the same WNDPROC that the main window's messages are routed to - what is the way of...
3
3736
by: Isabel | last post by:
How can you close all child browser windows that where open by a parent browser window? I have links on a parent (main) page that opens the child page as a separate browser. However, I need to be...
5
1503
by: Chris | last post by:
I have a form that requires drawing custom lines on it. The color of the lines is suppose to be the same as the forcolor of the form. Am I doing this the most efficent and correct way? ...
3
1658
by: Henry Jones | last post by:
I have a project that has 5 or 6 forms. VB.NET VS 2005 In the FormClosing Event of each form I have the following code: If Not IsNothing(frmA) Or Not frmA.IsDisposed Then frmA.Close() If...
29
2337
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
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...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4998
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...
0
4666
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...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.