Updating listbox using a thread in

18-Oct-2016 15:44

Threading; namespace Remote Monitor Server Now, when I start this code, the listbox does get "Programm started! There is no error in Visual Studio 2010, can someone please tell me what I'm doing wrong here?

Since threads cannot access form entities like listbox, i thought of using delegates.If the items come in bursts or require processing between adding each one, then you might want to think about running the processing behind the scenes (via a backgroundworker or a Task). However, I guess you could create the panel and list in the backgroundworker and then just pass it up to the UI to be plugged in by the main thread? Once the Background Worker is complete and you have all your Data, you can access your controls without issues and crossing threads.But, if you are just taking data and populating the list, then you are required to use the UI thread. So you simply swap the panel that's visible and set the List Box [email protected] Pihony I wouldn't exactly call it blocking the UI Thread.Following code in the below shows how i used a delegate to do that task, but it blocks the GUI form.so i just want to convert it to an asynchronous delegate which updates list box without blocking the GUI Form delegate declaration I have included your coding in a button click event.

Since threads cannot access form entities like listbox, i thought of using delegates.If the items come in bursts or require processing between adding each one, then you might want to think about running the processing behind the scenes (via a backgroundworker or a Task). However, I guess you could create the panel and list in the backgroundworker and then just pass it up to the UI to be plugged in by the main thread? Once the Background Worker is complete and you have all your Data, you can access your controls without issues and crossing threads.But, if you are just taking data and populating the list, then you are required to use the UI thread. So you simply swap the panel that's visible and set the List Box [email protected] Pihony I wouldn't exactly call it blocking the UI Thread.Following code in the below shows how i used a delegate to do that task, but it blocks the GUI form.so i just want to convert it to an asynchronous delegate which updates list box without blocking the GUI Form delegate declaration I have included your coding in a button click event.Organizing tasks in this manner allows the UI to remain responsive to user input while the background processing takes care of the data processing.