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

Thread: update form

  1. #1
    Join Date
    Nov 2005
    Posts
    102

    update form

    With what function can i update a form? Cause sometimes the painting of the window is going really slow. So i want to decide when to repaint the window form. How can i do that??

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: update form

    use the Refresh() method

  3. #3
    Join Date
    Nov 2005
    Posts
    102

    Re: update form

    I think the GUI is painted slow because i have a multithreaded application.
    One AsyncCallback thread, for the sockets connection.
    A timer for input events and another thread for rendering the game to the screen.

    Besides that i have a few User Controls that are drawn on top of the game.
    These User Controls are repainted VERY slow. The game itself and the input engine etc runs very smooth.

    Any idea how i could make the User Controls run smooth too??

  4. #4
    Join Date
    Nov 2005
    Posts
    102

    Re: update form

    Nobody any idea??

  5. #5
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: update form

    Quote Originally Posted by vivendi View Post
    Nobody any idea??
    Are you using double buffering already ?
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  6. #6
    Join Date
    Nov 2005
    Posts
    102

    Re: update form

    Yeh i do. I also have Application.DoEvents(). But that's not helping at all.

    I think my threads are messing up the thread that handles the UI. I used a few delegates, but no background workers... But on the other hand, by threads are async... Well anyway i'm so confused right now...

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

    Re: update form

    using DoEvents() in .NET is a bad idea and is *almost* never warranted. Also, I would use Invalidate() instead of Refresh() to repaint a control.

    That said, it's hard to help without knowing what your code is doing. You may be doing too much inside of your OnPaint handler, you may be refreshing too often, hard to say without seeing code. You can always upload your project here.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: update form

    Quote Originally Posted by vivendi View Post
    I think the GUI is painted slow because i have a multithreaded application.
    Probably not the issue unless the worker threads are set to a higher priority and are starving the UI thread.

    With regard to Application.DoEvents(). This is usually used to pump messages within a single threaded app doing a bunch of work in the UI thread that really should be a multithreaded app.

    Because your app is multithreaded, you definitely shouldn't need DoEvents, unless..... your UI thread is blocked waiting for one of the worker threads to complete the work. If that is the case, remove the blockage.

  9. #9
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: update form

    Try to boost the priority of your main UI thread.

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: update form

    Quote Originally Posted by vcdebugger View Post
    Try to boost the priority of your main UI thread.
    As a test sure, but generally this isn't a good idea in production.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured