Click here to Skip to main content
15,896,063 members
Home / Discussions / C#
   

C#

 
GeneralRe: Database not updating values - nullreference exception keeps getting throw Pin
Eagle3213-Mar-10 2:23
Eagle3213-Mar-10 2:23 
GeneralRe: Database not updating values - nullreference exception keeps getting throw Pin
Dan Mos13-Mar-10 13:06
Dan Mos13-Mar-10 13:06 
QuestionSpeed difference between two functions with unknown reason Pin
SimpleData12-Mar-10 10:10
SimpleData12-Mar-10 10:10 
AnswerMessage Closed Pin
12-Mar-10 10:17
stancrm12-Mar-10 10:17 
GeneralRe: Speed difference between two functions with unknown reason Pin
SimpleData12-Mar-10 10:18
SimpleData12-Mar-10 10:18 
AnswerRe: Speed difference between two functions with unknown reason Pin
Luc Pattyn12-Mar-10 11:00
sitebuilderLuc Pattyn12-Mar-10 11:00 
GeneralRe: Speed difference between two functions with unknown reason Pin
SimpleData12-Mar-10 11:06
SimpleData12-Mar-10 11:06 
GeneralRe: Speed difference between two functions with unknown reason Pin
harold aptroot12-Mar-10 11:31
harold aptroot12-Mar-10 11:31 
The point, as I understand it, was that calling fsB.get_Length (which is what you're doing when you ask the value of fsB.Length) may secretly be doing something that takes more than a reasonable amount of time, which is true.

As proof, here is the code for FileStream.Length
public override long get_Length()
{
    if (this._handle.IsClosed)
    {
        __Error.FileNotOpen();
    }
    if (!this.CanSeek)
    {
        __Error.SeekNotSupported();
    }
    int highSize = 0;
    int fileSize = 0;
    fileSize = Win32Native.GetFileSize(this._handle, out highSize);
    if (fileSize == -1)
    {
        int errorCode = Marshal.GetLastWin32Error();
        if (errorCode != 0)
        {
            __Error.WinIOError(errorCode, string.Empty);
        }
    }
    long num4 = (highSize << 0x20) | ((long) ((ulong) fileSize));
    if ((this._writePos > 0) && ((this._pos + this._writePos) > num4))
    {
        num4 = this._writePos + this._pos;
    }
    return num4;
}

Win32Native.GetFileSize uses P/Invoke to GetFileSize in kernel32.dll

Solution: store the length in a local variable (like Luc said)
GeneralRe: Speed difference between two functions with unknown reason Pin
Luc Pattyn12-Mar-10 11:41
sitebuilderLuc Pattyn12-Mar-10 11:41 
GeneralRe: Speed difference between two functions with unknown reason Pin
harold aptroot12-Mar-10 12:06
harold aptroot12-Mar-10 12:06 
GeneralRe: Speed difference between two functions with unknown reason Pin
Luc Pattyn12-Mar-10 12:29
sitebuilderLuc Pattyn12-Mar-10 12:29 
GeneralRe: Speed difference between two functions with unknown reason Pin
SimpleData12-Mar-10 22:35
SimpleData12-Mar-10 22:35 
GeneralRe: Speed difference between two functions with unknown reason Pin
SimpleData12-Mar-10 22:32
SimpleData12-Mar-10 22:32 
GeneralRe: Speed difference between two functions with unknown reason Pin
Pete O'Hanlon12-Mar-10 11:36
mvePete O'Hanlon12-Mar-10 11:36 
QuestionFloating child form linked to Treemap nodes Pin
boreland12-Mar-10 10:08
boreland12-Mar-10 10:08 
AnswerMessage Closed Pin
12-Mar-10 10:15
stancrm12-Mar-10 10:15 
GeneralRe: Floating child form linked to Treemap nodes [modified] Pin
boreland12-Mar-10 10:32
boreland12-Mar-10 10:32 
GeneralRe: Floating child form linked to Treemap nodes Pin
Dave Kreskowiak12-Mar-10 11:13
mveDave Kreskowiak12-Mar-10 11:13 
AnswerRe: Floating child form linked to Treemap nodes Pin
Luc Pattyn12-Mar-10 11:04
sitebuilderLuc Pattyn12-Mar-10 11:04 
GeneralRe: Floating child form linked to Treemap nodes Pin
boreland12-Mar-10 11:09
boreland12-Mar-10 11:09 
Questionabout remote desktop(noel) Pin
v_neil8712-Mar-10 8:54
v_neil8712-Mar-10 8:54 
QuestionHelp with C# Pin
Janded12-Mar-10 0:15
Janded12-Mar-10 0:15 
AnswerRe: Help with C# Pin
OriginalGriff12-Mar-10 0:59
mveOriginalGriff12-Mar-10 0:59 
GeneralRe: Help with C# Pin
riced12-Mar-10 4:42
riced12-Mar-10 4:42 
GeneralRe: Help with C# Pin
OriginalGriff12-Mar-10 4:53
mveOriginalGriff12-Mar-10 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.