Hello. My understanding about this class is that you should use it when you want to be sure that the Finalizer(destructor) or the class is called, but from a couple of tests I did, it doesn't seem to be true. If it does not make sure that the dispose method is called, is there any other way of doing it? For example, if i want to make sur...
I have a large 2GB file with 1.5 million listings to process. I am running a console app that performs some string manipulation then uploads each listing to the database.
I created a LINQ object and clear the object by assigning it to a new LinqObject() for each listing (loop).
When the object is complete, I add it to a list.
Whe...
My class contains an object from Interop and calls a method on it which causes it to alloc stuff. It also exposes a method to free that stuff, so I expect I should call this in Dispose():
class MyClass : IDisposable
{
private DllName.ComClassName comInstance;
void SomeMethod()
{
comInstance = new DllName.ComClassNam...
hi all
i am completely confused about close, dispose, finalize, GC, Idisposable.
Oh, could you please send me a clear description of them?
...
When you have code like:
Bitmap bmp = new Bitmap ( 100, 100 );
Graphics g = Graphics.FromImage ( bmp );
Pen p = new Pen ( Color.FromArgb ( 128, Color.Blue ), 1 );
Brush b = new SolidBrush ( Color.FromArgb ( 128, Color.Blue ) );
g.FillEllipse ( b, 0, 0, 99, 99 );
g.FillRegion ( b, pictureBox1.Region );
pictureBox1.BackColor = Colo...
Am I right that you'd only need a using() for the outermost stream if you're doing e.g
MemoryStream mstr = new MemoryStream();
using(StreamWriter w = new StreamWriter(mstr)) {
....
}
As disposing the StreamWriter should also dispose/close the underlying stream, there's no need to do this ?:
using(MemoryStream mstr = new MemoryS...
Updated 06/08/2009 15:52: Short answer NO. Original question:
I can't find any reference which gives guidance on SPWeb.Site regarding disposing. I've gone through some of the more popular best practises documentation on disposing SharePoint objects:
http://www.sharepointdevwiki.com/display/public/When+to+Dispose+SharePoint+objects
htt...
I have a simple WPF single window application contains Textboxes and Buttons. And I also use NotifyIcon and DateTimePicker of Windows Forms in WPF window. How can I effectively dispose all the controls?
...
it seem, after looking with reflector, that the sendasync(smtpclient) with the object token in the parameter of the function is byval
does it make sense to try to release the attachment in the callback function?
everywhere people(myself included) seem to do sendasync(mailmessage,mailmessage)
and in the callback(SendCompletedCallback) ...
I am using EntLib 4.1.
_db = DatabaseFactory.CreateDatabase("DbName");
DbCommand dbCommand = _db.GetStoredProcCommand("someProcedure");
_db.AddInParameter(dbCommand, "Id", DbType.Int32, id);
result = _db.ExecuteNonQuery(dbCommand);
After performing the task do I need to dispose the _db object, like:
finally
{
_db = null;
}
... ...
Given an application that maintains a singleton instance of a Runspace object (from System.Management.Automation.Runspaces) for the lifetime of the application, what are the potential side effects of failing to dispose of the Runspace before the application is terminated?
The design rationale I have been presented with is that memory/ha...
Hello.
I'm using a third party COM component by means of a .NET interop assembly in IronPython, as seen here: http://stackoverflow.com/questions/1237200/how-can-i-use-a-vb6-com-reference-in-ironpython
My experience in this area has been great, I'm very impressed by the amount of stuff that works seamlessly... except one thing.
The 3rd...
Potentially embarrassing question, but there is obviously something I'm missing that I want/need to know.
I expect the following code to create a new table row with new cells to be rendered later. And that's what it does ... as you would expect.
using (TableRow tr = new TableRow())
{
using (TableCell td = new TableCell())
{
...
I've written a class that does various modification to the contents of a SharePoint site. Inside that class, I've implemented a lazy resolved property
private SPWeb rootSite
{
get
{
if ( _site == null )
{
SPSite site = new SPSite( _url );
_site = site.OpenW...
Disposing a control from by calling its own BeginInvoke() is a good idea or bad idea? Or shall I use the parent control or something like that to accomplish this task?
I'm using Invoke because I'm accessing the control form another thread.
...
As an optimization, I decided to put an object I frequently need - an SDL surface with a prerendered image of the entire level (called S_AreaBMP) - at global scope.
Now it doesn't have to be created and destroyed in the DrawScreen function every frame. I only need to dispose and change it when a new level or GFX sheet is loaded, which I ...
As seems to be popular at the moment, if you implement a repository as simply
IQueryable<T> FetchAll<T>();
using LINQ to SQL, then the repository must set up a DataContext which remains available outside of the repository.
So my question is, How does the DataContext get Disposed?
What if an exception is generated by the code outside ...
After reading Stefan Gossner's post about disposing objects and this question about Cross method dispose patterns, I found that I was guilty of accidentally reopening some SPWebs. I know in Stefan Gossner's post he mentions you should dispose of an SPWeb after you are finished with any child object. However, the microsoft documentation m...
I am not a fan of boilerplate code: copy-paste reuse is potentially error-prone. Even if you use code snippets or smart templates, there is no guarantee the other developer did, which means there's no guarantee they did it right. And, if you have to see the code, you have to understand it and/or maintain it.
What I want to know from the...
I'm a total newbie at Entity Framework and ASP.Net MVC, having learned mostly from tutorials, without having a deep understanding of either. (I do have experience on .Net 2.0, ADO.Net and WebForms)
My current doubt comes from the way I'm instancing my Entities objects.
Basically I'm doing this in my controllers:
public class PostsCont...