Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: Responding to Web Browser generated MessageBox Pin
#realJSOP13-Mar-10 7:10
mve#realJSOP13-Mar-10 7:10 
QuestionDatabase not updating values - nullreference exception keeps getting thrown [modified] Pin
Eagle3212-Mar-10 13:13
Eagle3212-Mar-10 13:13 
AnswerRe: Database not updating values - nullreference exception keeps getting thrown Pin
Dan Mos12-Mar-10 13:36
Dan Mos12-Mar-10 13:36 
GeneralRe: Database not updating values - nullreference exception keeps getting thrown Pin
Eagle3212-Mar-10 13:56
Eagle3212-Mar-10 13:56 
GeneralRe: Database not updating values - nullreference exception keeps getting thrown[modified] Pin
Dan Mos12-Mar-10 14:01
Dan Mos12-Mar-10 14:01 
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 
Hi,
I have two methods, which are esentially doing similar jobs but have drastic speed differences. I don't know what is causing this speed difference. Here are the methods. The first one is like 100 times faster.

private void SaveNativeBinary(string file, long origin, long length, string opt)
        {
            SetSSVisible(StatusStrip, pbSmallPerc, true);

            FileStream fs = null;
            FileStream writer = null;

            try { fs = new FileStream(file, FileMode.Open, FileAccess.Read); }
            catch { throw new Exception("ERR"); }

            try { writer = new FileStream(opt, FileMode.Create, FileAccess.ReadWrite); }
            catch { throw new Exception("ERR"); }

            fs.Seek(origin, SeekOrigin.Begin);


            for (long pos = 0; pos < length; pos++)
            {
                if (pos % 204800 == 0) // 200KB'da bir güncelle
                {
                    SetSSValue(StatusStrip, pbSmallPerc, Convert.ToInt32(PercentageCalc(pos, length)) );
                    SetSSText(StatusStrip, lblStatus, "Aktarılıyor: " + BtoKB(pos).ToString() + " / " + BtoKB(length).ToString() + " KB (%" + PercentageCalc(pos, length) + ")");
                }
                writer.WriteByte((byte)fs.ReadByte());
            }

            fs.Close(); fs.Dispose(); writer.Close(); writer.Dispose();
            SetSSVisible(StatusStrip, pbSmallPerc, false);
        }


private void AppendBinToBin(string Container, string toAppend)
        {
            SetSSVisible(StatusStrip, pbSmallPerc, true);
            FileStream fsA, fsB = null;
            long tempLength = GetFileLength(toAppend);

            try { fsA = new FileStream(Container, FileMode.Open, FileAccess.ReadWrite); }
            catch { throw new Exception("ERR"); }

            try { fsB = new FileStream(toAppend, FileMode.Open, FileAccess.Read); }
            catch { throw new Exception("RRR"); }

            try
            {
                fsA.Seek(0, SeekOrigin.End);
                for (long pos = 0; pos < fsB.Length; pos++)
                {
                    if (pos % 204800 == 0) // 200KB'da bir güncelle
                    {
                        SetSSValue( StatusStrip, pbSmallPerc, Convert.ToInt32(PercentageCalc(pos, tempLength)) );
                        SetSSText( StatusStrip, lblStatus, "Aktarılıyor: " + BtoKB(pos).ToString() + " / " + BtoKB(tempLength).ToString() + " KB (%" + PercentageCalc(pos, tempLength) + ")" );
                    }
                    fsA.WriteByte( (byte)fsB.ReadByte() );
                }
                fsB.Close(); fsB.Dispose(); fsA.Close(); fsA.Dispose();
            }
            catch { throw new Exception("ERR."); }
            SetSSVisible(StatusStrip, pbSmallPerc, false);
        }


I am aware of the useless try-catch blocks, don't worry about them. They are not the cause of this speed difference.

Any help is appriciated.
Thanks.
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 
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 

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.