473,394 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Concensus on New parameters?

Can it be known what becomes of the Pen object in a call like:

Me.CreateGraphics().DrawLine(New Pen(Color.Red), 0, 0, 30, 30)

Typically, a Pen object should be disposed, and other objects may
require more significant resources, so I wonder if the pen is left for
the GC to finalize, or are the resources released after the call is
completed?

I am thinking this is such a handy way to pass parameters that the
compiler should be smart enough to know that we don't need the
resources after the call has finished, meaning it's Dispose method
should be 'automatically' called when the method has completed.

Is there any documentation that discusses this type of situation?

LFS
Nov 20 '05 #1
2 952
Larry,
Typically, a Pen object should be disposed, and other objects may
require more significant resources, so I wonder if the pen is left for
the GC to finalize, or are the resources released after the call is
completed?
Left for the GC like any other object.

I am thinking this is such a handy way to pass parameters that the
compiler should be smart enough to know that we don't need the
resources after the call has finished, meaning it's Dispose method
should be 'automatically' called when the method has completed.


I don't see how the compiler could assume that. The method you're
calling could store a reference to the object for later use.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #2
* "Larry Serflaten" <se*******@usinternet.com> scripsit:
Can it be known what becomes of the Pen object in a call like:

Me.CreateGraphics().DrawLine(New Pen(Color.Red), 0, 0, 30, 30)

Typically, a Pen object should be disposed, and other objects may
require more significant resources, so I wonder if the pen is left for
the GC to finalize, or are the resources released after the call is
completed?

I am thinking this is such a handy way to pass parameters that the
compiler should be smart enough to know that we don't need the
resources after the call has finished, meaning it's Dispose method
should be 'automatically' called when the method has completed.


In your case, I would use 'Pens.Red' ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
3
by: Bill Cart | last post by:
The oldDb Command does not support Named Parameters. If I am reading them correctly, the docs say that the order of the parameter should match the order they are declared in the Stored Procedure....
2
by: Mark | last post by:
I created a test to check the execution time difference between executing a SQL Server stored procedured using explicit parameters versus not. In one case I created new SqlParameters in the code,...
4
by: Tim::.. | last post by:
Can someone tell me a better way or give me a link that shows a better way to create large numbers of SQL parameters... Example... A better way to write this code! <code> Sub...
1
by: Mikey G | last post by:
Hi, I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...

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.