|
Sorry you are write
Calling Dispose allows the resources used by the Stream to be reallocated for other purposes.
Flushing the stream will not flush its underlying encoder unless you explicitly call an implementation of Flush or Close. Setting AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly.
Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream
Taken from MSDN
<l>Thanks and Regards
Sandeep
|
|
|
|
|
sharpiesharpie wrote: if you dispose after you close it throws an exception
If it does, it's a bug in the implementation. You should be able to call Dispose any number of times, and if the object already has been disposed, it should ignore it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
IMHO:
Flush() is meaningful only if you dont plan on closing right away; it means "send this
through, before I produce more".
I use Flush() when tracing a program's progress to a file, so when the program suddenly
crashes, the file contains all traces including the very last that was called.
FileStream.Dispose():
on .NET 1.1 only exists as Dispose(bool) and is protected, you cant call it;
you should call Dispose() for each object that offers a public Dispose(), but you cant
call a protected one (unless you are inheriting from the class).
on .NET 2.0 exists and is public but the doc says "is not intended to be used directly
from your code", so dont call it !
Close() is the one that MUST be called, it tells everything is done. And according to
the doc it calls Dispose(bool) itself.
Conclusion:
call either Flush() if you plan on producing more but want to make sure what you already
have gets processed, or Close() if you're done. Dont call both.
BTW looking at the (current) implementation is not a sound base for deciding what
function to call, reading the doc is.
|
|
|
|
|
sharpiesharpie wrote: fs.Dispose();
fs.Close();
Close and Dispose in this class are synonyms of each other - they do the same thing.
As implemented, Close() calls Dispose() which, in turn, calls Flush()
Flush writes out anything remaining in the buffer to the file.
|
|
|
|
|
Colin Angus Mackay wrote: As implemented, Close() calls Dispose() which, in turn, calls Flush()
Actually, they don't call Flush . I just double-checed that through Reflector. The call order is backwards as well: Dispose does call Close , which then calls a protected Dispose(bool) method which actually does all of the work.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Scott Dorman wrote: I just double-checed that through Reflector
Ummm... I got my information through reflector.
Dispose calls close on an object of a class called __HandleProtector , not FileStream .
public override void Close()
{
this.Dispose(true);
GC.nativeSuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (this._handleProtector != null)
{
if (!this._handleProtector.IsClosed)
{
this.Flush();
}
this._handleProtector.Close();
}
this._canRead = false;
this._canWrite = false;
this._canSeek = false;
this._buffer = null;
}
public override void Flush()
{
if (this._handleProtector.IsClosed)
{
__Error.FileNotOpen();
}
if (this._writePos > 0)
{
this.FlushWrite();
}
else if ((this._readPos < this._readLen) && this.CanSeek)
{
this.FlushRead();
}
}
|
|
|
|
|
err...so...what's the best way to do it? flush + close?
and...how can i see the objects and classes? (the premade ones), the object browser right?
|
|
|
|
|
sharpiesharpie wrote: err...so...what's the best way to do it? flush + close?
Since closing and disposing both get around to flushing the stream, why bother flushing it yourself?
|
|
|
|
|
We are looking at two different versions of the Framework. What you show is correct for .NET 1.1. For .NET 2.0 and later, the implementation is what I described. Here are the full details:
Since FileStream inherits the Close() and Dispose() methods from Stream , reflector shows the following for Stream :
public virtual void Close()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
public void Dispose()
{
this.Close();
}
protected virtual void Dispose(bool disposing)
{
if (disposing && (this._asyncActiveEvent != null))
{
this._CloseAsyncActiveEvent(Interlocked.Decrement(ref this._asyncActiveCount));
}
} Since Flush() is an abstract method, the FileStream class implements it as:
public override void Flush()
{
if (this._handle.IsClosed)
{
__Error.FileNotOpen();
}
if (this._writePos > 0)
{
this.FlushWrite(false);
}
else if ((this._readPos < this._readLen) && this.CanSeek)
{
this.FlushRead();
}
}
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Dispose and Close are equivalent, so you can call either one (or both).
Flush will write the contents in memory to the file (the stream's backing store).
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I need the procedure on how and when to use (add) the crystal report "product key" during deployment of crystal report application (.Net 2005), since it is requied to validate the licence of the crystal report windows app.
Banjo Ayorinde
|
|
|
|
|
Hy
A class who create a MyTextBox and have a constructor who create a new TextBox.
I need to make a propertyGrid with the property of the MyTextBox (e.g. left,top,width,height), but in the propertygrid i see the properties of the MyTextBox and the properties of the TextBox.
How can I do to hide the properties of the TextBox and show only the property of the MyTextBox.
10x
|
|
|
|
|
hi,
i did it some other way (by inheratance... and overrides the properties of tha bease class... the ones i didn't want to see were marked with
[Browsable(false)]
before the methode...
if yourtextbox is a property or public variable, i guess you can use this also...
greetz
kurt
|
|
|
|
|
10x ... working.
But other is the problem
MyTextBox inherit a class MTextBox who have a TextBox mtb = new TextBox(); and a property Mtb
and when I create MyTextBox myTB = new MyTextBox(); and put it into the propertyGrid the myTB, I can see the Mtb property who have the exact property of an TextBox object.
I want to not see the Mtb in my propertyGrid ... and I tried with [Browsable(false)] and it isn't work.
Do u think it's another solution?
10x
|
|
|
|
|
verify....
so you placed this code into your MTextBox class ?
private textBox mtb;
[Browsable(false)]
public textBox Mtb
{
get { return mtb;}
set { mtb = value;}
}
that should work..
Not sure but otherwise override the methode in your MyTextBox class and do the same...
|
|
|
|
|
This is the base class:
public abstract class MgrComponentBase
{
Control _baseControl = new Control();
[Browsable(false)]
public Control BaseControl
{
get { return _baseControl; }
set { _baseControl = value; }
}
[CategoryAttribute("Properties"), DescriptionAttribute("Something")]
public string ComponentName
{
get { return BaseControl.Name; }
set { BaseControl.Name = value; }
}
...
This is the second Class:
public class MgrTextBox : MgrComponentBase
{
string _label;
string _tooltipText;
[Browsable(false)]
public MgrTextBox()
{
BaseControl = new System.Windows.Forms.TextBox();
}
public System.Drawing.Color BackgroundColor
{
get { return BaseControl.BackColor; }
set { BaseControl.BackColor = value; }
}
public System.Windows.Forms.TextBox TextBox
{
get { return (TextBox)BaseControl; }
set { BaseControl = value; }
}
...
and doesn't work.
|
|
|
|
|
this one is not neccessary for the constructor..
[Browsable(false)]
public MgrTextBox()
{
BaseControl = new System.Windows.Forms.TextBox();
}
what if youset the propertygrid to the MgrComponentBase
class??
i think overriding the BaseControl property in the MgrTextBox class should help you..
[Browsable(false)]
public override Control BaseControl
or
[Browsable(false)]
public new Control BaseControl
{
get { return base.baseControl; }
set { base.baseControl = value; }
}
|
|
|
|
|
Hi,
I have loaded a dataset with a table that contains 1000 records. so far so good.
When loaded i assign my Datagridview.Datasource event with the table, but this takes 4 seconds before i actualy see the records in my grid.
DgvCardHolders.DataSource = DsCardHolders.Tables[0];
Does someone have an idea how to show the progress of this load ?
i suppose the datagridview is copying the data from the datatable.
Thx
Kurt
|
|
|
|
|
Okay,
here i am again....
2 posibilities...
THE PROBLEM :
The property AutosizecolumnsMode was set to Allcells and that's whats making it slow.. so i set it to Alldisplayedcells and guess, no performance problem at all.... over 3000 records in no time on screen.. (so don't tell me delphi is faster now...no way.. just do it the right way.)
STILL WANTS A PROGRESS BAR :
If u still want to use AllCells and show a progress bar a solution is using virtualmode. Switch the property on and use the cellvalueneeded event to fill in the grid values.. in this event you can calculate the progress using the e.index and the row.count and show it on screen while loading. Don't use the Datasource property in this case.
Greetz
Kurt
Belgium.
|
|
|
|
|
Hello, I have a control, that creates a dialog using ShowDialog() method of a Form class. The problem is that sometimes it happens, that another application shows instead of the created dialog. I have tried passing null as an active window should be used. Tried passing the control, that creates the dialog, but no better, the window dissappears. Now I'm just experimenting with BringToFront(), Activate(), but no luck.
Any help would be appreciated, thanks a lot for your time ...
|
|
|
|
|
Maybe settings your own application topmost at that moment ???
your application and your dialog will remain on top of all other windows..
otherwise search for main windowhandles of other apps and hide them by a windowsmessage, but thats a lot of work i guess...
greetz
|
|
|
|
|
Hi
I have written an application in which on left side there are oulook style menu.When i click anyone from that menu a new child form open in panel control of parent form.
My problem is that this child form is not getting focus .i HAVE ALSO TRIED .FOCUS AND .SELECT methods.
if i donot add this child form in panel control then form gets focus but on maximizing child form it also covers the area of left created menus.
So how i can get focus on child form in panel control ? or how i restrict child form not extend from specified left position on maximization.
I am using Visual Studio 2005 c# windows form
|
|
|
|
|
myChildForm.Activate();
Geniality is in simplicity.
|
|
|
|
|
Yes i tried this one also but child form not getting focus in panel
|
|
|
|
|
Also note that if there is text box on child form and in this scnerio if you click text box you can type text in it but cannot select the text in textbox by simply mouse selection(draging mouse).
|
|
|
|