Controlling Objects

G

Guest

Given following code to instantiate object, how does one:
1) check a specific objects health - running, dead etc.
2) call a method in a specific object in the multiple object set
3) terminate a specific object

foreach ( DataRow ConfigRow in DSWTG.Tables["TurbineConfiguration"].Rows )
{
switch ( ConfigRow["Turbine Type"].ToString())
{
case "V47":
// instantiate a new turbine
VestasWTG V47 = new VestasWTG( TagNameRow, ConfigRow);
break;
default:
break;
}
}
 
N

Nicholas Paldino [.NET/C# MVP]

FredC,

I don't know what you mean by an object's health. An object doesn't
have a health. If you have a reference to it, you can call what you want.
It's not something you need to worry about.

As for calling a specific object in a multiple object set, again, what
do you mean by this? Do you mean a specific object in the array? If that
is the case, you can just access the array through the indexer, and then
call the object like any other.

The only case you have to worry about when you are done with an object
is if it implements the IDisposable interface. If it does, then you have to
make sure to call the implementation of Dispose on that instance when you
are done with the instance itself. Otherwise, you don't have to worry about
getting rid of objects. Just release your references (by setting to null in
class fields, or if a local variable, doing nothing), and you will be fine.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top