|
-
Jan 8th, 2004, 05:21 PM
#1
Thread Starter
New Member
Can't interact with UI w/ thread processi
OK, this doesn't make much sense, but....
On my form_load I start a thread whose sole purpose is to allow me to see and interact with the form while the thread populates a listview with a lot of data.
If I do this...
-------------------
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim thd as new Thread(AddressOf PopulateListview)
thd.Start()
End Sub
Private Sub PopulateListview()
'populate listview code here
End Sub
-------------------
...then it allows me to interact with the UI without error while it populates the listview (I've tried this with other controls and recieved exceptions). YES, I am aware that I am not supposed to do this from a thread that the control wasn't created on. So, to make it reliable, I decided to do it the right way (I think)...
-------------------
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim thd as new Thread(AddressOf PopLV)
thd.Start()
End Sub
Private Sub PopLV()
BeginInvoke(New CtrlHandle(AddressOf PopulateListview))
End Sub
Private Delegate Sub CtrlHandle()
Private Sub PopulateListview()
'populate listview code here
End Sub
-------------------
...Now it works the same (making be feel better about working with the listview), but I cannot interact with the UI until the process is done. AND, whether the cursor is a pointer or hourglass is based on how I set the priority of the thread (and I've tried them all).
I'd like to be able to interact with the UI during the population process. Any help on this would be greatly appreciated!
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
|