Re: threading & suspendlayout

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 05/27/04


Date: Thu, 27 May 2004 09:32:18 +0100

2G <2G@pandora.be> wrote:
> I've a usercontrol that fills a listview with data from my db, I had
> this.SuspendLayout() in the beginning and this.ResumeLayout at the end of
> the function that loads the data and all worked fine. But now that I have
> threaded the function (refreshdata), the SuspendLayout and ResumeLayout()
> doesn't work any more, I tried solving it with Invoke() but with no succes.
> public UserControl1(){
>
> this.SuspendPaint += new DSuspendPaint(this.SuspendPaintProc);
> }

You're using Invoke for the SuspendLayout and ResumeLayout calls, but
it looks like you're still filling the listview from your worker
thread, which you shouldn't be. *Everything* which touches the UI
should be done from the UI thread.

I'm not sure why you've got a SuspendPaint event, either...

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: Exposing usercontrol components at design time
    ... The name of the UserControl listview does ... not get updated in the properties window until I reload the form, ... > the Controls property of your USerControl. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Exposing usercontrol components at design time
    ... Windows Explorer GUI Controls ... > I want to allow design time modification of components on a usercontrol. ... > added a listview called listView1 to the usercontrol, ... > Is there a way to eliminate the redundant listview "Add"? ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Problem Grösse UserControl
    ... Habe mein eigenes UserControl, das vereinfacht ... Passe die ClientSize des UserControls an die Size des ListView an ... Prev by Date: ... Next by Date: ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: wegen UserControl
    ... Oder nimmst halt eine Variable her die mit WithEvents deklariert ist und die ... private WithEvents lv as ListView ... Event im UserControl definiert, welches angetriggert wird, wenn das ListView ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Multiple nested FlowLayoutPanel causes very poor performance
    ... I have written a UserControl which creates a simple layout of some ... If you ever played around with FlowLayoutPanels, ... I did alot of reading about SuspendLayout and ResumeLayout, ...
    (microsoft.public.dotnet.framework.windowsforms)