|
-
Jun 23rd, 2014, 03:30 PM
#1
[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!
-
Jun 23rd, 2014, 04:17 PM
#2
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.
-
Jun 23rd, 2014, 04:40 PM
#3
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!
-
Jun 23rd, 2014, 04:51 PM
#4
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.
-
Jun 23rd, 2014, 05:06 PM
#5
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!
-
Jun 23rd, 2014, 05:09 PM
#6
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.
-
Jun 23rd, 2014, 05:16 PM
#7
Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load
 Originally Posted by ident
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.
-
Jun 23rd, 2014, 11:44 PM
#8
Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load
 Originally Posted by ident
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!
-
Jun 24th, 2014, 12:35 PM
#9
Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load
 Originally Posted by opus
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?
-
Jun 24th, 2014, 01:03 PM
#10
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!
-
Jun 24th, 2014, 01:13 PM
#11
Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load
 Originally Posted by opus
, 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.
-
Jun 24th, 2014, 02:35 PM
#12
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!
-
Jun 24th, 2014, 02:44 PM
#13
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
-
Jun 24th, 2014, 05:20 PM
#14
Re: [RESOLVED] UserControl doesn't refresh corretly when application is in heavy load
 Originally Posted by Gruff
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|