Reduce lag while loading a VERY big list?[Solved]

Posts 1–10 of 10 · Page 1 of 1
Reduce lag while loading a VERY big list?[Solved]
Ok guys so for one of my programs it loads a list that can have anywhere from 50,000-100,000 items on it, it then scrolls through all of the items, selects them and does stuff with them. As you can imagine this is incredibly laggy Is there anyway i can reduce the lag besides application.doevents? (i have that in there now makes little to no difference) i was thinking maybe using background worker but i have no idea how to do that D:
Multithreading.

Put all your code in a sub or multiple subs.

[php]
Dim t as new threading.thread(addressof subname)
t.start
[/php]

You may also set the threads priority.
Although BackgroundWorker is much more flexible than Normal Threads, Normal Threading in your case will work great like Kevin said. Each BackgroundWorker has built in delegates that allows you to report progress and notify you when the Asynchronous (The code runs in seperate thread, means main programs runs smoothly) task has finished, which gives you much more control
All of the above, plus I thought I'd add some. If you're going to be doing threading, best learn about delegates rather than being lazy with "CheckForIllegalCrossThreadCalls = False" when accessing controls from a different thread. They seem fucking confusing, but once you get it, it's pretty easy... for basic shit anyway
Quote Originally Posted by Jason View Post
All of the above, plus I thought I'd add some. If you're going to be doing threading, best learn about delegates rather than being lazy with "CheckForIllegalCrossThreadCalls = False" when accessing controls from a different thread. They seem fucking confusing, but once you get it, it's pretty easy... for basic shit anyway
Exactly.

Within multithreads you cannot access gui controls i.e. buttons/textboxes or anything like that. You can ofc access your variables in it.

There are two methods to avoid this.

1. Delegates

[php]Public Delegate Sub Dele()
Public Sub ToDelegate()
'your code
End Sub

'the call
Me.Invoke(New Dele(AddressOf(ToDelegate)), Nothing)[/php]

or...

2.

Put the following on form_load

[php]Control.Checkforillegalcrossthreads = false ' NOT me.[/php]
Quote Originally Posted by Blubb1337 View Post
Exactly.

Within multithreads you cannot access gui controls i.e. buttons/textboxes or anything like that. You can ofc access your variables in it.

There are two methods to avoid this.

1. Delegates

[php]Public Delegate Sub Dele()
Public Sub ToDelegate()
'your code
End Sub

'the call
Me.Invoke(New Dele(AddressOf(ToDelegate)), Nothing)[/php]

or...

2.

Put the following on form_load

[php]Control.Checkforillegalcrossthreads = false ' NOT me.[/php]

Incorrect delegate is incorrect
Quote Originally Posted by Jason View Post



Incorrect delegate is incorrect
Haha...Pawned
Ahh yeah i got it, ty guys, especially blub1337
/care. I just copied it from somewhere.
Quote Originally Posted by Blubb1337 View Post
/care. I just copied it from somewhere.
Of course...
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us