dispose

Java CountDownLatch used to wait for JFrame to dispose

I have referenced this previous question as well as other sources, but cannot get CountDownLatch to work correctly. Background: mainFrame creates new Frame called dataEntryFrame. When dataEntryFrame "Submit" button is clicked, record added to database and dataEntryFrame disposed. At this point, mainFrame should clear and reload a jL...

Call Dispose() on a WindowsIdentity object? C#

I am retrieving a WindowsIdentity object by calling: win_id = System.Security.Principal.WindowsIdentity.GetCurrent(); with the intention of getting the currently logged on user name, which works fine. WindowsIdentity implements IDisposable, but since I din't create the object myself, do I still need to call .Dispose() on it when I am...

System Tray Application and Memory Footprint

Hello everyone, I have created a small application that, basically, exists in the system tray and the user only needs to open the actual application in VERY few cases. The problem is, that once the suer opened the application for the first time, the memory is filled up with an awful lot of data (WPF UI for datagrids, treeviews etc). But...

Do COM Dll References Require Manual Disposal? If so, How?

I have written some code in VB that verifies that a particular port in the Windows Firewall is open, and opens one otherwise. The code uses references to three COM DLLs. I wrote a WindowsFirewall class, which Imports the primary namespace defined by the DLLs. Within members of the WindowsFirewall class I construct some of the types de...

Recursion in Unity and Dispose pattern implementation

My class is inherited from UnityContainer (from Unity 2.0), here is source code: public class UnityManager : UnityContainer { private UnityManager() { _context = new MyDataClassesDataContext(); // ... } protected override void Dispose(bool disposing) { ...

Ninject and DataContext disposal

I'm using Ninject to retrieve my DataContext from the kernel and I was wondering if Ninject automatically disposes the DataContext, or how he handles the dispose() behaviour. From own experiences I know disposing the datacontext is pretty important and that whenever you create a direct object of the DataContext (as in: new DataContext())...

How to close a JFrame in the middle of a program

public class JFrameWithPanel extends JFrame implements ActionListener, ItemListener { int packageIndex; double price; double[] prices = {49.99, 39.99, 34.99, 99.99}; DecimalFormat money = new DecimalFormat("$0.00"); JLabel priceLabel = new JLabel("Total Price: "+price); JButton button = new JButton("Check Price")...

Why is 'using' improving C# performances

It seems that in most cases the C# compiler could call Dispose() automatically. Like most cases of the using pattern look like: public void SomeMethod() { ... using (var foo = new Foo()) { ... } // Foo isn't use after here (obviously). ... } Since foo isn't used (that's a very simple detection) and si...

How to dispose when application crashes

Hi, got a issue: I create singleton helper object that wraps PerformanceCounter objects. It implements IDisposable... But now I have spotted that when I close my test sample console host application, counters are still visible in perfmon tool (in production I will be hosted in Windows Service) , and are still running. I figured out th...

java swing program not closing after dispose is called on last window

Preface: This is the first real swing program I have done. I have a swing program, where one JButton is supposed to exit the program. That button triggers this.dispose();. When i click this JButton, it does make the window completely go away, but looking at the debugger, the program itself is still running. My main method only consists...

C# CA2000:Dispose objects before losing scope using FileStream/XmlTextReader

I have lots of code like this: FileStream fs = File.Open(@"C:\Temp\SNB-RSS.xml", FileMode.Open); using (XmlTextReader reader = new XmlTextReader(fs)) { /* Some other code */ } This gives me the following Code Analysis warning: CA2000 : Microsoft.Reliability : In method 'SF_Tester.Run()', object 'fs' is not disposed along all ex...

NHibernate ISession and automatically flushing/committing transactions in my unit of work.

I have created an IDbContext object that is provided to my IRepository implementations. The DbContext provides a way for my business logic to create, commit and rollback transactions and commits as needed. It also transports my NHibernate ISession, so my NHibernate implementation of IRepository can access it. I am using this setup in a ...

Use of Garbage Collection?

Hi, I want to know what action is performed when we call Dispose() method. Is Object frees all resources quickly on Dispose() call or Dispose() marks the Object is ready for garbage collection. And What happened when we set Object reference to NULL. Actually I have Windows form application in .NET 2.0. And I want to call garbage collecto...

Why would I need to call dispose on ASP.NET Controls?

I'm doing some ASP.NET development in VS and have just found an interesting little code suggestion (I think they come from coderush but I could be wrong). Whenever I'm creating controls it tells me that I should be using a "using" statement for them. I'm a bit confused as to what is going on here though. with the using my code looks som...

When do I need to use dispose() on graphics?

I'm learning to draw stuff in C# and I keep seeing recommendations to use dispose(), but I don't quite understand what it does. When should I be using dispose() on a code-drawn graphic? What happens if I don't? Do I need to call it every time a graphic is not visible, such as on a GUI that has tabs and the user switched to the other t...

.NET FINALIZE CONCEPT PROBLEM

Is it really better not to use finalize compare to dispose ? Does dispose remove unmanaged resource in first parse ? What is suppressing finalize ? ...

linq System.ObjectDisposedException

Hi, i have a problem with some data i retrievied from db with linq. When I try to access data I obtain the following exception: System.ObjectDisposedException : The istance of ObjectContext was deleted and is not possible to use it again for action that need a connection. This is the code: using (ProvaDbEntities DBEntities = new ProvaDb...

how to create and manage wcf service clients?

At first I treated them as any dependency passing them in the ctor to the class consuming the service: var serviceConsumer = new ServiceConsumer(new MailingServiceClient()) The problem was that once an exception was thrown from the service it entered a faulted state and would not reply to any requests, so re-initialization was due. F...

What is the difference between Dispose and Close?

Possible Duplicate: Close and Dispose - which to call? Hi, After reading some web pages, I still don't understand the difference between Dispose and Close methods in C#. Let's take a sample: using (SqlConnection sqlConnection = new SqlConnection()) { // Execute an insert statement (no breaks, exceptions, returns, etc.) ...

Do I need to Release inner objects of a COM Interop object?

I have a managed class that uses a COM that looks like this. Public Class MyClass Private myobj as SomeComObject Public Sub New() myobj = CreateObject("SomeComObject.Class") End Sub Public Sub DoSomething() dim innerobj as SomComObject.InnerClass innerobj = myobj.CreateInnerClass("arg1", true, ...