473,654 Members | 3,076 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 1806
You can use Deactivate event of the Child Form with a timer.

private void ChildForm_Deact ivate(object sender, System.EventArg s 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.u k> wrote in message
news:eX******** **********@fe1. news.blueyonder .co.uk...
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.co m

"Paul Aspinall" <pa**@aspy.co.u k> wrote in message
news:eX******** **********@fe1. news.blueyonder .co.uk...
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**********@h otmail.com> wrote in message
news:OL******** ******@TK2MSFTN GP09.phx.gbl...
You can use Deactivate event of the Child Form with a timer.

private void ChildForm_Deact ivate(object sender, System.EventArg s 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.u k> wrote in message
news:eX******** **********@fe1. news.blueyonder .co.uk...
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
6489
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 -------------- using System.ComponentModel; ....
8
4928
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, System.EventArgs e) { MessageBox.Show("keyboard button pressed!"); } Following is the code to load the frmTestBaby
2
11843
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 form. The KeyUp event of Child1 form load another form Child2 and close the Child1 form. the problem is when I close ActiveMdiChild of the Parent form, which is Child1 at the moment, it closes both Child1 & Parent Form. I want to close...
4
2236
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 Dispose(bool Disposing) { if (Disposing) { if (components != null) {
4
2022
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 identifying from the lParam or wParam whether the message came from a child window or the parent? And what if the message uses some other data in the wParam or lParam? Is it better to use one wndproc for the parent window, and one wndproc for all child windows...
3
3743
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 able to close all the opened child browser pages from the parent page. Thank you for your help, Isabel
5
1516
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? Thanks.... Protected mPen As Pen Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) If mPen Is Nothing Then mPen = New Pen(Me.ForeColor)
3
1673
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 Not IsNothing(frmB) Or Not frmB.IsDisposed Then frmB.Close()
29
2365
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 what is an unmanaged resource? Does everything need disposing? I've been using Webrequest, Webresponse, Streamreaders etc. How can I be sure of what needs disposing? Do these get automatically get disposed of at the end of the procedure...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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
8707
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...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
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...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
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 we have to send another system
2
1593
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.