B
Beren
Hello,
I'm having a thread that retrieves data from a website, stores it into an
array, and raises an event in the form thread to populate a listbox.
As soon as the first item is to be added (even if it's no part of the array,
but something random) my application is irresponsive for some seconds.
I pass the array to the event handler in the eventargs. Something like :
sub threadproc
while bMorePages()
getResultsFromNextPage()
fireEvent(myarray)
end while
end sub
sub fireEvent(myarray)
dim args as new eventargs(myarray)
raiseEvent(Me,args)
end sub
' // And in the event handler on the form
' // it goes a bit like :
' // e = eventargs
sub eventhandler()
synclock Me
Dim li as listviewitem
while i < e.myarray.length
application.doevents()
li = new listviewitem()
li.text = e.myarray(i)
'// freezes on i = 0
myListbox.items.add(li)
'// continues
i += 1
end while
end synclock
end sub
While debugging I noticed the application freezes when the first item is
added to the listview
As you can see, the thread continues as long as there are more pages
(bMorePages = True), and never freezes again in this cycle,
only when the very first item is added in the listbox.
I get accurate results, but the add command freezing the application is
terribly annoying.
Can anyone help ?
Thanks,
Beren
I'm having a thread that retrieves data from a website, stores it into an
array, and raises an event in the form thread to populate a listbox.
As soon as the first item is to be added (even if it's no part of the array,
but something random) my application is irresponsive for some seconds.
I pass the array to the event handler in the eventargs. Something like :
sub threadproc
while bMorePages()
getResultsFromNextPage()
fireEvent(myarray)
end while
end sub
sub fireEvent(myarray)
dim args as new eventargs(myarray)
raiseEvent(Me,args)
end sub
' // And in the event handler on the form
' // it goes a bit like :
' // e = eventargs
sub eventhandler()
synclock Me
Dim li as listviewitem
while i < e.myarray.length
application.doevents()
li = new listviewitem()
li.text = e.myarray(i)
'// freezes on i = 0
myListbox.items.add(li)
'// continues
i += 1
end while
end synclock
end sub
While debugging I noticed the application freezes when the first item is
added to the listview
As you can see, the thread continues as long as there are more pages
(bMorePages = True), and never freezes again in this cycle,
only when the very first item is added in the listbox.
I get accurate results, but the add command freezing the application is
terribly annoying.
Can anyone help ?
Thanks,
Beren