|
Also destructors do exists in C# .NET. They are compiled into Finalizer method in the IL.
If one thinks that by the timeGC to start its next collection, the application runs out of memory, GC.Collect() could be handy. But I would always try to avoid it. As a matter of fact I have never used it.
|
|
|
|
|
Guffa wrote:
they will not be garbage collected unless you run out of memory.
That's not true, they will be collected before you run out of memory. They will be collected whenever the garbage collector deems necessary, which isn't always when you run out of memory.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Guffa wrote:
If you create a lot of ArrayList objects in a loop, they will not be garbage collected unless you run out of memory.
That's not the entire truth: GC will also run before it tries to allocate more memory.
|
|
|
|
|
The ArrayList itself is a managed class. Just let it go out of scope, and it will be gracefully garbage collected.
If the ArrayList contains references to unmanaged resources, you have to dispose of these resources when your class is disposed. You should implement the IDisposable interface if your class handles unmanaged resources.
As the ArrayList may contain references to other objects, call the Clear method when you don't need the list any more. If the ArrayList doesn't contain references to other objects, it will be easier for the garbage collector to remove it.
---
b { font-weight: normal; }
|
|
|
|
|
Hello !!
I've been programing in Visual Studio 2003 and now i change IDE to Visual Studio 2005 Beta 2 and of course .NET 2.0 Beta. I converted the project i was doing and i run it. It show lots of runtime errors of Thread Safe because it looks like Windows.Forms is no longer a Thread safe operation (why have they change this???? don't have a clue). How can i call these objects in another thread? i know it has something to do with "Delegate" or "control.Invoke" but i think this has change too.
Please help me.
thanks !!
Sorry for my English...
Bruno Conde
pharaoh
|
|
|
|
|
The operations that you speak of were allow to be written in kind of a shortcut fashion in 2003, but shouldn't have been. You have to rewrite the code to follow the more strict threading rules of 2005.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Windows Forms has NEVER been thread safe! In fact, Win32 common controls have never been thread safe. Even the new UI coming in Windows Vista is not thread safe. In .NET 1.1, the application would run ok for awhile, but you'd run into subtle bugs eventually. In .NET 2.0, a error is issued if you try to use Windows Forms controls from another thread.
If you want to use a Windows Forms control from another thread, use the Control.Invoke and Control.BeginInvoke methods:
void CalledFromAnotherThread()
{
myTextBox.Invoke((ThreadStart)myTextBox.Invalidate);
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Cops & Robbers
Judah Himango
|
|
|
|
|
Hi,
I want to be able to mute and unmute sound in Windows from my C# app. However, I have no idea where to start. Can someone give me some good links or sample code?
Thanks in advance
|
|
|
|
|
This is a CPP article and sample.
http://www.codeproject.com/com/VoiceMeter.asp
|
|
|
|
|
Hello. I also dont know or worked so far with the system Sound but i think that is only possible with Microsoft DirectX. Download it and try.
Bruno Conde
pharaoh
|
|
|
|
|
winmm.lib is the key. It has the API to control the System Volume.
|
|
|
|
|
Just tried the dx sdk, but it seems it cannot handle system volume or something :S
Going for the lib now
|
|
|
|
|
A good sleep does good on you thinking. I found out my own how to solve this problem. Just emulate the Mute button on your keyboard, and it will do
|
|
|
|
|
I have one form which I want to display on one tab page of tab control on another form. is it possible that I can place that form as a control on a panel control or directly on the tab control ?
|
|
|
|
|
You cannot add a Form in the Panel Control. You have to use a UserControl instead.
|
|
|
|
|
Actually, you can. See my reply to the OP.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It can be done, but it's not obvious how to do it.
Read this[^] article on MSDN and it'll show you exactly how to do it. The samples are in VB.NET, but it's easy to convert to C#.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thats really cool. I am using .NET for 4 years now but never knew it.
Thanks.
|
|
|
|
|
I think this just solved an unrelated problem I had, with a MDI Child that needed to show a "child" form of its own. It was acting really strange...
Anyway, I think this gives me an idea of what to try, and thanks for the link, very interesting.
Sue
|
|
|
|
|
Yeah, MDI Parent's can only have one set of children and MDI Children are not allowed to have children of their own. The onyl way around this limitation (imposed by Windows, not the .NET Framework) is to treat a form as a control.
Since the Form class derives from Control,
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.ContainerControl
System.Windows.Forms.Form
a Form can be hosted in any container that can accept a System.Windows.Forms.Control object.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hai Friends,
I had one doubt.Why interface in c#.net doesn't support fields?
But Java interface supprots fields.How it is possible in java?
Any body knows the answer mail me.
Thnaks & Regards,
Manimala
|
|
|
|
|
Interfaces supports fields in java? That is strange.
Strictly oop speaking, fields should not be public at all, but only be accessible through properties. An interface only defines public members, so it should not contain fields.
Furthermore, specifying fields in an interface would force you to implement them in exactly that way, which is exactly opposed to the purpose of interfaces.
Also, specifying fields in an interface could make interfaces collide. If two interfaces specify the same field names, you could not inherit both interfaces in a class.
---
b { font-weight: normal; }
|
|
|
|
|
|
I'm searching a way to make a Form transparent to clicks. I mean that if the Form is clicked, the click will not be stopped, but it has to be sent behind the Form, to the next window or to the desktop. This behavior must be also used for mousedown, mouseup, and so on.
Please help...
Thanks
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is getting rid of us.
|
|
|
|