Secondary Thread
-
I’ve a WinForm application and a TreeView control on it. I’m creating another thread to add data to the control. So far I’m able to achieve this behavior, but sometimes secondary thread is not destroyed. I know it is not recommended, but I’d like to know more about my options and why I should not do this. Thanks
-
I’ve a WinForm application and a TreeView control on it. I’m creating another thread to add data to the control. So far I’m able to achieve this behavior, but sometimes secondary thread is not destroyed. I know it is not recommended, but I’d like to know more about my options and why I should not do this. Thanks
You should be able to do this, but you can't do the actual update from the second thread. At least not reliably. You'll need to use Control.Invoke() on the treeview control. Create a function that does the add on the control, create a delegate to it, and pass the delegate and the parameters to Invoke(). It will then get called on the main UI thread.