S
Shirim9
Hi All,
I have a question about getting the combobox values
(combobox.selecteditem) during threading.
There is a Sub that does alot of calculations as below and i know if i
put maxnum = combobox.selecteditem, there will be cross-thread
problem. I don't quite know how to get the selected values in the
combobox. I have tried to search around for some clues and found it
may have to use BeginInvoke and EndInvoke? However i'm not exactly
sure whether this is right way and how to use it. If anyone can kindly
show an actual implementation of how to get the values.
Thanks a lot
Btw, below is just a illustration that i was trying to do.
Private Sub backgroundSub()
Dim i, maxnum as integer
maxnum = Cint(combobox.selecteditem) ' This will cause cross-thread
problem and i don't know how to solve
for i = 1 to maxnum
'Do calculations here
Next
End Sub
'Sub runs when user click this button
Private Sub Button1_Click()
Dim u As New System.Threading.Thread(AddressOf backgroundSub)
u.Start()
'Do other things
End Sub
I have a question about getting the combobox values
(combobox.selecteditem) during threading.
There is a Sub that does alot of calculations as below and i know if i
put maxnum = combobox.selecteditem, there will be cross-thread
problem. I don't quite know how to get the selected values in the
combobox. I have tried to search around for some clues and found it
may have to use BeginInvoke and EndInvoke? However i'm not exactly
sure whether this is right way and how to use it. If anyone can kindly
show an actual implementation of how to get the values.
Thanks a lot
Btw, below is just a illustration that i was trying to do.
Private Sub backgroundSub()
Dim i, maxnum as integer
maxnum = Cint(combobox.selecteditem) ' This will cause cross-thread
problem and i don't know how to solve
for i = 1 to maxnum
'Do calculations here
Next
End Sub
'Sub runs when user click this button
Private Sub Button1_Click()
Dim u As New System.Threading.Thread(AddressOf backgroundSub)
u.Start()
'Do other things
End Sub