Memory eater
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Memory eater

  1. #1
    Join Date
    Feb 2012
    Posts
    2

    Lightbulb Memory eater

    Hey!

    I use the following piece of code(Not mine!) to wait for the web browser to fully load the page.
    It works perfect but its not good for the memory because this method is used allot.

    Any optimization tips?
    Code:
    private void waitTillLoad(WebBrowser webbrowser)
            {
                WebBrowserReadyState loadStatus;
                //wait till beginning of loading next page 
                int waittime = 100000;
                int counter = 0;
                while (true)
                {
                    loadStatus = webbrowser.ReadyState;
                    Application.DoEvents();
    
                    if ((counter > waittime) || (loadStatus == WebBrowserReadyState.Uninitialized) || (loadStatus == WebBrowserReadyState.Loading) || (loadStatus == WebBrowserReadyState.Interactive))
                    {
                        break;
                    }
                    counter++;
                }
    
                //wait till the page get loaded.
                counter = 0;
                while (true)
                {
                    loadStatus = webbrowser.ReadyState;
                    Application.DoEvents();
    
                    if (loadStatus == WebBrowserReadyState.Complete)
                    {
                        break;
                    }
                    counter++;
                }
            }

  2. #2
    Join Date
    Feb 2012
    Posts
    2

    Re: Memory eater

    bump!


    anyone ?

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Memory eater

    Why do you think this consumes too much memory? Have you profiled your app? I see nothing in there that would be problematic (well, I would probably launch the browser asynchronously instead of waiting in a loop and doing ugly thing like DoEvents()) as far as memory is concerned. It looks to me like you are making an assumption about the performance of your code that is ill informed and most likely false.
    If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.

    Yes; I have a blog too - http://the-angry-gorilla.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center