"the state has for 60 seconds, with the target context of threads/cell is likely to perform pump waiting for or in the case of no Windows messages sent to deal with a running time is very long, this usually affects performance, may even lead to the application does not respond or use memory constantly accumulated over time, to avoid this problem, all the single thread unit pump should be used (STA) thread is waiting for primitives (like CoWaitForMultipleHandles), and in the process of the long-running operation regularly sends the message," abnormal
Why do most of the file browser software, click on a folder node, has just finished loading? Is it in the cache? I am just learning WPF don't have to be new, to simulate file browsing interface, compile results slow more than 10 seconds, what is the solution, optimized? Speed up the execution of code? Or make a paging? Or use asynchronous programming load (thread I haven't learned, you can consider it if short learning time to finish it), can say in what way is better, paging, speed up the execution of code, asynchronous programming load or other methods (preferably not upgrade computer configuration),
Code
//click this button to load a one-time loading large listviewitem node, the node corresponding to a picture
Private void button_Click_1 (object sender, RoutedEventArgs e)
{
DirectoryInfo TheFolder=new DirectoryInfo (@ "scenery pictures E: \ ");
String a=a DateTime. Now. The ToString ();
Foreach (the FileInfo NextFile in TheFolder. GetFiles ())
{
If (System. IO. Path. GetExtension (NextFile. FullName)==". BMP "| | System. IO. Path. GetExtension (NextFile. FullName)==" JPG "
| | System. IO. Path. GetExtension (NextFile. FullName)=="PNG")
{
ListViewItem b=new ListViewItem ();
B.W idth=120;
Thickness thick=new Thickness (10);
B.M argin=thick;
Listview1. Items. The Add (b);
The StackPanel sp=new the StackPanel ();
Biggest ontent=sp;
Sp. HorizontalAlignment=HorizontalAlignment. Center;
Sp. VerticalAlignment=VerticalAlignment. Center;
Image ig=new Image ();
Ig. Source=new BitmapImage (new Uri (NextFile. FullName));
Ig. Stretch=Stretch. Uniform;
Ig. Height=90;
TextBlock TB=new TextBlock ();
TB. Text=System. IO. Path. GetFileNameWithoutExtension (NextFile. Name);
TB. Height=50;
Sp. Children. The Add (ig);
Sp. Children. The Add (TB);
}
}
}
CodePudding user response:
Listbox and listview are not suitable for present large amounts of data control, almost no optimization, paging, or use the GridView, rewrite the template, more easily than listview controlCodePudding user response:
pageCodePudding user response:
Lazy loading, can like mobile phone brush weibo, first part load, such as drag down when loading part, or add a "load more" at the bottom button, click to load more content, such an approach to estimate your code changes will be relatively small,CodePudding user response: