Implementation Of IDisposable Into Classes

Mar 8, 2009

I implemented IDisposable into one of my classes, but don't know if I did it correctly. Can someone tell me what will be cleared from memory and what will remain after calling .Dispose on an instance of this class? [Code]

View 5 Replies


ADVERTISEMENT

Bad Implementation Of IDisposable?

Oct 20, 2009

I am a budding MCTS so I am not a 100% sure of whether I am correct in this instance.I am looking through a windows forms application created by a developer who has left our company some time ago. Within the code I have found a custom form derived from the standard form baseclass which explicity implements IDisposable.The custom form does not call any COM object or do any file IO operations and has only one database call which is closed and disposed off in the method that calls it. However within the code of the form there is the following,[code].....

Looking at this am I right in thinking that this should be removed including the implements IDisposable line at the top of the form since,

1. The listeners collection will go out of scope when the form does as the collection only references listener objects (which do not implement IDisposable).

2. The controls do not explicitly need disposing, since when the form goes out of scope this will be done anyway.

View 4 Replies

Change The Implementation Functino Of IDisposable?

Dec 30, 2009

just wondering if we could change the implementation functino of IDisposable.Dispose to a private. because the default i've got something like this:

[Code]...

Protected Overridable Sub Dispose(ByVal disposing As Boolean) or could i take away the the Protected Overridable and replace it with a Private access modifier?

View 9 Replies

IDE :: Interaction Of Finalize And Default Implementation Of IDisposable() Interface?

Apr 20, 2009

I am comparing an alternative Dispose pattern to VS2005's default implementation. In doing the comparison I have found several uncertainties with the default pattern which have raised a handful of questions related to sub-class implementations and object Finalization.

[Code]...

View 1 Replies

Should All Classes Implement IDisposable Interface

Jul 19, 2010

i may be misunderstanding this but on MSDN i believe it says that it is good practice to implement the Dispose destructor in every class you write. should i (do you) really implement the IDisposable interface with every class i write? also, is the proper syntax for implementing an interface to put the "Implements" keyword on the line after the "class" declaration? i put it on the same line as "class" and I got an error.when coding the method implemented by the interface, is it mandatory to follow this syntax, as an example: Public Sub Dispose() Implements System. IDisposable. Dispose.

View 3 Replies

VS 2008 Singleton Factory Implementation - Is Pattern Implementation Right

Mar 18, 2010

So I've been doing some research on the singleton factory design pattern, and I am wondering if my example implementation is correct (warning I did get carried away creating animals):

[Code]...

View 6 Replies

C# - When Should Implement IDisposable

Mar 12, 2010

What is the best practice for when to implement IDisposable? Is the best rule of thumb to implement it if you have one managed object in the class, or does it depend if the object was created in the class or just passed in? Should I also do it for classes with no managed objects at all?

View 6 Replies

Using Statement - Can With/End With (VB.NET) Be Used When IDisposable Is Not Available

Feb 6, 2011

In cases where Using can't be used because IDisposable is not implemented, is the following code an OK practice for With/End With? Would this cause a memory leak or would it be better to set an instance variable and then set it to nothing?

With New System.IO.FileInfo(sFileName)
' Do some work
End With

View 3 Replies

VS 2008 Use IDisposable?

May 21, 2009

I have been working on this for a while now. And I am still confused about some issues. My questions below

1) I know that you only need a finalizer if you are disposing of unmanaged resources. However, if you are using managed resources that make calls to unmanaged resources. Would you still need to implement a finalizer?

2) However, if you develop a class that doesn't use any unmanged resources directly or indirectly and you implement the IDisposable so that clients of your class can use the 'using statement'. Would it be acceptable to implement the IDisposable just so that clients of your class can use the using statement?

[Code]...

View 4 Replies

IDisposable - RegisterHotkey And UnregisterHotkey Functions

Jan 25, 2010

I'm using the RegisterHotkey and UnregisterHotkey functions

Code:
<DllImport("user32.dll")> _
Private Shared Function RegisterHotKey(ByVal hWnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As UInteger, ByVal vk As UInteger) As Boolean

[CODE]...

I have a Hotkey class that is (should be) responsible for calling UnregisterHotkey. I want to take it out of the users' hands to ensure that UnregisterHotkey will always be called when the object is destroyed. Would that be IDisposable or something else?

View 1 Replies

Design Patterns - Implement The IDisposable Interface With A Dispose?

Apr 21, 2009

Recently I needed to compare a suggested pattern for IDisposable and object finalization with the auto-generated one we which VS2005/VB.NET provide. We have used the auto-generated one a fair bit, but after looking it the two side by side I had a number of questions about the VB.NET implementation..

[Code]...

Overall I am confused by the supposed added value of having an extended code-path that executes when Dispose() is called explicitly(as opposed to having a common path that is executed regardless of whether or not Dispose() was called explicitly). how it does anything other than delay the actual release of managed resources if Dispose() isn't called directly. In essence it seems to only work to make the managed resources unreachable in the object graph, orphaning them until the 2nd GC run rather than freeing them at a point where they are known to be no longer needed.

View 3 Replies

Use LINQ To Filter Collection Of Nested Classes To Yield Dictionary Of Unique Properties Of Those Classes?

Jan 23, 2012

I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.

View 2 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?

Oct 24, 2009

Here is some example code of what I mean:

vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click

[Code]....

View 5 Replies

Derived Classes Cannot Raise Base Classes

Jul 10, 2009

I m trying to raise Click event of Textbox explictly but I m getting "Derived classes cannot raise base classes" error.[code]....

View 1 Replies

How To Auto-insert A Code Snippet When Implementing Interface Like When Implementing IDisposable

Aug 10, 2010

Is it possible to automatically insert a Code Snippet when an interface is implemented? If so, how do you do it? I am looking for something similar to when you implement IDispoable in VB.[code]This will be used by web forms when transfering parameters from one page to the next using Server.Transfer

View 1 Replies

Implementation Of C++ Code In .net ?

Aug 20, 2009

I have developed a C++ program code .Now, I want to access this code in VB.net .

View 2 Replies

Loop And Enumerate Properties Of Nested Classes In Nested Classes?

Sep 24, 2010

so far i got

code
For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields
rtfAppend(item.Name & ":" & Tab & item.GetValue(Me))
Next
For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()

[code]...

which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?

View 1 Replies

.net - IBindableComponent Interface Implementation ?

Jan 19, 2011

I need to implement the IBindableComponent to the the following code:

Public Class InfragisticsToolStripBindableButton
Inherits Infragistics.Win.UltraWinToolbars.ButtonTool
Implements IBindableComponent

[CODE]...

1 problem: Warning: event 'Disposed' conflicts with property 'Disposed' in the base class 'DisposableObject' and should be declared 'Shadows'

2 problem: Error: Class 'InfragisticsToolStripBindableButton' must implement 'Property Site As ISite' for interface 'System.ComponentModel.IComponent'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.

Why should I implement "IComponent" if I implement "IBindableComponent"?

3 problem: How should I override "Dispose", if it's already implemented in the base class, but is not virtual apparently.

View 1 Replies

.net - Performance Of Implementation Of IComparer?

Jul 14, 2011

I'm sorting a collection of type "Document" (usually around 100k records). Sorting usually takes around 4-5 seconds, and I'm wondering if there's a way to speed up sorting by modifying my "DocumentComparer" class which implements IComparer(Of Document). Since the Compare() method would be called hundreds of thousands of times, are there any performance improvements that could be made here that I've overlooked?

[Code]...

View 2 Replies

.net - Some IBindableComponent Interface Implementation?

Feb 8, 2011

I need to implement the IBindableComponent to the the following code:

Public Class InfragisticsToolStripBindableButton
Inherits Infragistics.Win.UltraWinToolbars.ButtonTool
Implements IBindableComponent

[code].....

View 2 Replies

2d - .NET Liang-Barsky Implementation?

Nov 6, 2010

After some research, I've decided to use the Liang-Barsky line clipping algorithm in my 2D game. Google did not deliver on any VB.NET implementations of this algorithm but plenty C/++ ones. Therefore, as I have knowledge in C++, decided to port one found on Skytopia over to VB.Net. Unfortunately, it does not work with:

Public Class PhysicsObject
Public Function CollideRay(ByVal p0 As Point, ByVal p1 As Point, ByRef clip0 As Point, ByRef clip1 As Point) As Boolean
Dim t0 As Double = 0.0
Dim t1 As Double = 1.0

[code]....

However, the CollideRay method fails on its 3rd edge iteration (edge = 3), r < t0, therefore the function returns false.

View 1 Replies

Asp.net - Error On An Icomparer Implementation

Nov 12, 2010

I created an array sorter to sort arrays like in Win Explorer in a DNN module. As in the answer to a preview question: Sorting an array of folder names like Windows Explorer (Numerically and Alphabetically) - VB.NET

[Code]....

View 1 Replies

C# - Free Implementation Of Printf?

Mar 1, 2010

The problems:

I can't use string.Format, I have C style format strings;I can't call the native printf (no P/Invoke);I can't use http://www.codeproject.com/KB/printing/PrintfImplementationinCS.aspx because of the license, I need something GPL-compatible.Is there a free implementation of printf/sprintf for the .net framework? Other than the above link, I couldn't find anything.

I cooked up a sprintf function that supports basic format strings, you can find it here: [URL].. I'll try to make it a complete implementation if I can.

View 3 Replies

Conversion Types For DLL Implementation?

Aug 23, 2010

I need to use some functions from a DLL written in C++. Problem is when I try to use those functions in VB (Visual Studio). The only way I get to pass the debugger without errors is if I use the VariantType type, but I get all screwed up values. Can anyone tell me how can I "translate" the use of char [6] into VB from C++? My problem when Implementing is with the variable INFO, the content comes back after execution with errors..This is the original code from the DLL Manual:

Code:
Int Get_Info(A Handle, char *IPAddr, InfoType *Info)
where the parameters:
A [IN] Handle.
IPAddr [IN] IP address

[code]....

View 4 Replies

Convert C# Event Implementation To VB?

Apr 11, 2012

I am trying to use some C# code that expands on the GridView functionality in a VB.NET project. The code I'm using is from here.

In the C# code there is an event definition for GroupHeader [code]...

View 2 Replies

Interface Implementation Deference?

May 21, 2010

What is the diference of using interfaces like ...I have an interface

Public Interface IProDataSource
Function read() As Integer
End Interface[co]....de

The only difference I have notice is that if the method is declare private it will be visible using the first approach only.

View 3 Replies

Is LinkedList Implementation Of .Net Threadsafe

Apr 26, 2011

I am working on an application which uses multiple threads to work on number of tasks and the parent application receives the output of the task,later to be written to files, currently I am using arraylist to append output to, but that happens to be slow when removing items from queue.I was thinking to convert arraylist part to linkedlist for optimized reads and clears,if linkedList Implementation of .Net is threadsafe or even using arraylist was threadsafe?

View 3 Replies

Our App Uses: ASP.Net, .Net, And Microsoft's AJAX Implementation?

Mar 3, 2011

The middleware that manages talk between the mainframe and our app is blowing up randomly. It's a "such and such attempted to read/write protected memory..." error.The vendor is saying there we must be running some unmanaged code (I feel they're trying to worm out of it). I know VB's entirely managed, but does anyone know about the server portion of AJAX? Is there any server side javascript stuff that occurs before it actually gets into the .NET framework?

View 1 Replies

Program To An Interface Instead Of Implementation?

Dec 25, 2009

I have been reading about design patterns and application architecture and im told that I should program to an interface instead of implementation. This i understand. So I figured I would start with something small. Never programmed with an interface before. So I want to create an encryption program that will allow the user to select which method to encrypt it with, AES, DPAPI, etc. I started designing the Interface but I am unsure if I am doing this right. [Code] Also, when it comes to the DPAPI implementation, how is the client supposed to supply the Protection Scope? I didn't think this should be in the interface as it only applys to the DPAPI.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved