Threading in c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Threading in c#

Any one can explain it to me Or provide some documentation for it I can launch background workers but I can’t get the result of operation or make the background worker control any object in the form And I would like to make a cancel button that can kill any process the form is doing or specific process Any documentation would be good for me So I can understand what I need to make what I have mentioned work ❤️

19th Aug 2020, 5:13 PM
oday
oday - avatar
3 Answers
0
Hi. Background workers are generally used for short time functions. If your code runs high amount of time that you need a cancel button is better if you use thread objects. For controlling objects in the forms you need to do modifications of the properties in the same thread that creates the object. Use the Invoke property for this and check the link for more info. https://docs.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls
20th Aug 2020, 7:01 PM
Benjamin Alejandro Luna
Benjamin Alejandro Luna - avatar
0
the program needs to connect to sql data base and store some data between once and while but the form freez during that time and background worker or threading can remove this I want to avoid system termnating the program of user to do so but I seem to be unable to get output from the thread or background worker to know if the process has completed without errors the thread canot control any part of the form like txt box and write in it ‘done’ for example can you help with that ?
21st Aug 2020, 12:24 PM
oday
oday - avatar
0
In the link i gave you explains how to do that.
21st Aug 2020, 5:38 PM
Benjamin Alejandro Luna
Benjamin Alejandro Luna - avatar