|
Hi..
No it's not private.
You can Implement an Interface in 2 ways.
First:
<br />
public class Blah:IDisposable<br />
{<br />
public void Dispose()<br />
{<br />
}<br />
}<br />
in This case you can say:
<br />
myBlahObject.Dispose();<br />
But, when you Implement it that way:
<br />
public class Blah:IDisposable<br />
{<br />
void IDisposable.Dispose()<br />
{<br />
}<br />
}<br />
<br />
myBlahObject.Dispose();<br />
will not work. but if you say:
<br />
(myBlahObject as IDisposable).Dispose();<br />
it works fine
hope this helps
greets
m@u
|
|
|
|
|
Thanks for the swift reponse m@u.
I used Lutz Roeder's excellent .NET Reflector (http://www.aisto.com/roeder/dotnet/) to query SqlDataReader in the 1.1 System.Data.dll, which gives the following result when viewing the Dispose method: -
private void Dispose(bool disposing);
This is why I stated that the Dispose method is private. (If I use Reflector to query an assembly with Dispose implemented as 'void IDisposable.Dispose();', it doesn't show
the method as being private).
Strange, isn't it?
Regards,
David.
|
|
|
|
|
ok well that's now something completly different
the Dispose(bool disposing) which is normally marked as protected virtual, is used, because you can not inherit interface Implementations.
if you look at the IDisposable Interface, you see, that the Dispose Method doesn't take any Parameters (Dispose()
now let's say you have an abstract class called myAbstractClass and you want to implement the IDisposable Interface on it. so your object looks like
<br />
public abstract class myAbstractClass:IDisposable<br />
{<br />
public abstract void Blah();<br />
void IDisposable.Dispose()<br />
{<br />
}<br />
}<br />
and now you want to implement a class, that extends this abstract class. so you make a new class called myImplementedClass
let's say, you have some variables in myImplementedClass , that you need to clean up when the object dies.
so you do:
<br />
public class myImplementedClass:myAbstractClass<br />
{<br />
private ClassThatNeedsToBeCleanedUpOnDispose foo;<br />
public override void Blah()<br />
{<br />
}<br />
public override void Dispose()
{<br />
}<br />
}<br />
as you see, this code will not work, because you can not override an Interface - Implementation.
so you have to modify the code of your base class. and that's where Dispose(bool disposing) comes in. because the new Code of your myAbstractClass will look like this:
<br />
public abstract class MyAbstractClass:IDisposable<br />
{<br />
public abstract void Blah();<br />
void IDisposable.Dispose()<br />
{<br />
Dispose(true);<br />
}<br />
protected virtual void Dispose(bool Disposing)<br />
{<br />
}<br />
}<br />
and now your new myImplementedClass looks like this:
<br />
public class myImplementedClass:myAbstractClass<br />
{<br />
private ClassThatNeedsToBeCleanedUpOnDispose foo;<br />
public override void Blah()<br />
{<br />
}<br />
protected override void Dispose(bool Disposing)<br />
{<br />
if (Disposing)<br />
{<br />
base.Dispose(Disposing);<br />
}<br />
}<br />
}<br />
<br />
now every class, that derives from your basic class or from a class that is derived from your basic class can implement Dispose(bool Disposing)
now you can say somewhere in your code
<br />
myAbstractClass blah = new derivedfromthederivedClassFrommyAbstractClass();<br />
(blah as IDisposable).Dispose();<br />
and every class in the inerit-chain of the derivedfromthederivedClassFrommyAbstractClass will dispose correctly because it has implemented Dispose(bool Disposing)
do you see now what Dispose(bool Disposing) is for?
i can't exactly tell you why reflector shows that as private, because that doesn't make sense, but normally, if you implement it as protected it's because of this here..
greets
m@u
|
|
|
|
|
Please I want app to make a form as a Monitor for my computer to show on the Form ,
Can any one give my the name of this program ,
|
|
|
|
|
Hello,
I was wondering if i am getting you correctly ..
you want the backgound of your form as desktop or what ???
Please clear the question
nishu
|
|
|
|
|
I am sorry , I want
1- 2 froms
2- the first one will appear the desktop , adn you know in the desktop my computer,documents like this .
3- i will open my computer through the first form ,this action will appear on the form2
.
if you dont understand my question
i can write it in another form.
thank you very much
|
|
|
|
|
that would be better..
nishu
|
|
|
|
|
our application would need:
1.import data(stock prices) from websites into a database(excel sheets)
2.interfacing excel sheets with the asp application
3.performing manipulations on the data and draw corresponding graphs(line,bar,..)
4.make the application accessible on a network
are asp.net and C# apt for the application?
can someone please help us with relevant code?
regards
ps:please reply asap
besides our email add are:
funwithsiddartha@gmail.com
lovelyritesh_in@yahoo.com
shobhit.samaria@gmail.com
abhinavsharma0507@gmail.com
|
|
|
|
|
Do You basically going to manipulate a excel by .net application?
|
|
|
|
|
yes that is what we had in mind. if it is possible to call the functions of excel from .net then nothin like it or else we would like to develop similar functions in our program.
thnx
|
|
|
|
|
Yes, is possible
In your project you need add reference COM Microsoft Office XX Object Library
where XX is the version of MSOffice that you'll work.
The namespace is Microsoft.Office.Interop.Excel
If you look in for this namespace you going to find many examples.
Isn't too easy, but isn't impossible
|
|
|
|
|
hi alex!
thnx for helping us.
if u can send us some sample code of such interfacing it would be much easier to understand
by the way where r u from and wat do u do?
this is part of our engg project that we are seeking help for.
regards
|
|
|
|
|
Well, I'm going to send a example for you with copy for emails in the first post
I'm from Brazil, I'm .net developer, my english is poor but I can communicate...
|
|
|
|
|
hi alex,
u said u wud b sending us a sample code for calling the functions of excel from
asp.net. if u have the code plz send it to us asap. we r waiting.
regards
|
|
|
|
|
Sorry...
But these days I'm in vocation
Now I came back
See the code below to open a Excel App.
<br />
ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();<br />
Workbooks oBooks = excel.Workbooks;<br />
object nulo = System.Reflection.Missing.Value;<br />
<br />
oBooks.Open("C:\\file.xls",nulo,false,nulo,nulo,nulo,nulo,nulo,nulo,true,nulo,nulo,nulo,nulo,nulo); <br />
<br />
_Workbook b = oBooks.get_Item(1);<br />
|
|
|
|
|
Hello...
Does anybody know how to get the <TITLE> from a HTML site ?
For example : this.webBrowser.Navigate("http://www.codeproject.com");
If the loading is finished, then I want to get the "The Code Project - Free Source Code and Tutorials".
Thanks...
-- modified at 8:55 Thursday 15th February, 2007
|
|
|
|
|
Never used the webbrowser control, but after a quick glance at the docs I guess the DocumentTitle property is what you're looking for.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
well I've this trouble, I need to close all the windows in my app....
I'm using MDIForms.
To close some forms I use this code above:
foreach(Form frm in this.MdiChildren)//when this is my MDIParent
{
frm.Close();
}
seems simple but I need to close ShowDialog Forms (ShowDialog isn't a MDIChild), when one ShowDialogForm is open I can't to close it, It's still open, How do I'll to close it?
Thanks
|
|
|
|
|
Alex
I am still a newbie at C# also but I am developing a MDIApplication and I am using a Login form as a dialog. To close that form I have put a close button on the form and then used the code this.dispose(); as the way to close it.
private void button1_Click(object sender, EventArgs e)
{
this.dispose();
}
Hope this helps!
Allan
Allan F. Gagnon
|
|
|
|
|
You should use the Close method instead of Dispose to close your login form.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks Allan
But I can to close one window....
The problem is many windows.. I'm going to explain my app, when time expire I need to close all windows that are open, however, some of these windows are ShowDialog, when I execute the sample code above the only windows that are closed are the MDIChildren, however, ShowDialog windows not is MDIChild and therefore still open, I can't handle these.
I don't know who is owner of theses windows ShowDialog()
I'm tired..
|
|
|
|
|
Hi..
In my application i have a situation where for particular period of time
specific no.of threads are created in SmartThreadPool..
And its working fine..
Now i want to dequeue some of the Thread items from the ThreadPool,
to stop the Threads..
I'm not sure how to get this..
Please help me..
For pooling i'm using SmartThreadPool.
thanks,
nas
|
|
|
|
|
Hello,
I think you would have to call the Aport method of the thread instance.
All the best,
Martin
|
|
|
|
|
Hi,
In C# 2005 I need a hint how to solve if there is a control on a form and I click or select it in design-time, the Click event is fired in design-time. Important that in design-time! How can I catch the OnClick event or anything else in design-time? Also for Control or any ToolStripItem, like ToolStripButton.
Please help, it's important!
Thanks,
Attila
|
|
|
|
|
if ( this.DesignMode ) {
this.ProcessDesignTimeClick(e);
}
else{
this.ProcessRunTimeClick(e);
}
Geniality is in simplicity.
|
|
|
|