dcsimg
Results 1 to 14 of 14

Thread: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Resolved [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    I use a UserControl which consists of several Buttons and 2 PictureBoxes.
    If the application is in a reasonable load (recieving messages over a UDP connection) those controls a displayed as planned. On command "SetA" (PictureBoxA and ButtonA) is displayed while SetB is hidden and PictureBoxA.BackgroundImage gets updated on each TimeStep.
    If under heavy load (other worker-threads) however such a command does NOT result in a immidiate correct of the displayed "SetA", only the deselected controls are hidden and the BackGround of the UserControl is shown. The correct display is coming up after "some" time. What is even more disturbing, when clicking on the position where ButtonA should be, the repective _Click routine is run??????????????
    I'm using such code to command the change in display:
    Code:
     Private Sub btnActive_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnActive.Click
            ActiveMode = Not ActiveMode
            PictureBoxA.Visible = NotPictureBoxA.Visible 'either PictureBoxA or PictureBoxB is shown! 
            PictureBoxB.Visible = Not PictureBoxB.Visible
            ButtonA.Visible = Not ButtonA.Visible
        End Sub
    I don't see something like vthat on controls directly on my Form, only on the UserControl. Does anybody know the reason for that?
    Aren't UserControls handled with the same priority as the other controls?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,329

    Re: UserControl doesn't refresh corretly when application is in heavy load

    How are you invoking these controls? I can't see how any control makes a difference.

  3. #3

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: UserControl doesn't refresh corretly when application is in heavy load

    Invoking? To my undersanding the code posted above is performed directly on the GUI thread, isn't it?
    When it comes to be showing the results of those workerthreads, I'm using Events which are treated on the GUI thread. All of that is verified with less load.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,252

    Re: UserControl doesn't refresh corretly when application is in heavy load

    Have you tried calling the .Refresh method on the controls right after changing their visible state? A lot of times thats all you really need to do when code on the GUI is also busy.

  5. #5

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: UserControl doesn't refresh corretly when application is in heavy load

    .Refresh!!!!!!!!!!!
    Why didn't I think of that?
    -Resolved-
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,329

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Events are still called by which ever thread calls it. Refresh seems like a cheap hack like doevents to me.

  7. #7
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,252

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Quote Originally Posted by ident View Post
    Events are still called by which ever thread calls it. Refresh seems like a cheap hack like doevents to me.
    Works for me , and has never effect any of my GUI code AFAICT.

    Control.Refresh Method
    Forces the control to invalidate its client area and immediately redraw itself and any child controls.

  8. #8

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Quote Originally Posted by ident View Post
    Events are still called by which ever thread calls it.....
    Sorry for my ignorance, however I decided not to show all the code used nor discribe all to steps needed and used to make an event be handled on the GUI. I was hoping you would take the " All of that is verified with less load." as a sort of proof.
    IMHO it has to be a "not refreshed" display, otherwise the click on a "not visible" button wouldn't be possible (Isn't it weird to click "somewhere" and the not displayed Button is working?)
    The .Refresh also works for the picturebox, which normally gets filled over time, however in heavy load the updated wasn't shown as it was calculated but only some time later but with the complete misssing history at once.
    BTW, I tried an .Invalidate for the whole UserControl, which didn't work for both observed problems, .Refresh did work!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  9. #9
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,252

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Quote Originally Posted by opus View Post
    BTW, I tried an .Invalidate for the whole UserControl, which didn't work for both observed problems, .Refresh did work!
    So you only had to .Refresh the UC and not each control inside the UC?

  10. #10

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    In case of the code posted above "Me.Refresh" did work.
    In the case of the PictureBox (the code I didn't post), I used the .Refresh directly on the PictureBox directly after PictureBox.Invalidate()
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  11. #11
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,252

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Quote Originally Posted by opus View Post
    , I used the .Refresh directly on the PictureBox directly after PictureBox.Invalidate()
    Do you you really need to call PictureBox.Invalidate and then PictureBox.Refresh?, I thought .Refresh would invalidate it anyway and take care of it.

  12. #12

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Actually I didn't test with only .Refresh until now.
    The result of the test did surprise me.
    With only .Refresh the late picture update (with the complete history) was back even in a normal load.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  13. #13
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    When I create user or inherited controls I tend to paint what I need when I need it rather than bulk up the control with sub controls. You save resources and things tend to display quicker.
    Burn the land and boil the sea
    You can't take the sky from me


    ~T

  14. #14

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load

    Quote Originally Posted by Gruff View Post
    When I create user or inherited controls I tend to paint what I need when I need it rather than bulk up the control with sub controls. You save resources and things tend to display quicker.
    So?
    What do you I'm doing? The delayed display of the updated picturebox is NOT wanted! What makes you think that I'm bulking up sub controls?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width