Updating textbox asynchronously
So, we are returning our abstract asynchronous operation to the caller.
Before you begin this tutorial, you should have a solid base knowledge of all C#'s fundamental concepts, and have at least a general knowledge of the different API's available for performing multithreaded and asynchronous operations in C#.
The examples are kept very very simple, but basic knowledge is still required So, what has brought this on?
Well, I responded to this thread made in the C# forum today about the standard cross thread communication issues that we have all faced when using multithreading in a GUI environment.
For example, we have all seen code like this to marshal updates onto the UI thread, I am sure: then made a very good point about how it is usually better to decouple the operation running on a background thread from the UI, so I'd like to provide a few examples , and expand on this point.
For example, you could have a class called Prime Number Calculator, have a method called Calculate() to calculate the numbers, and have an event called Primes Calculated when the calculation was complete), and the work is always going to return a string as a result (just for example's sake, you can change this, or make it more general if you wish (return a generic This concept is very closely related to the Event Based Asynchronous pattern, and, thus, in many cases, you may be able to use built in classes that already implement that pattern (or perhaps sub class those classes, and add custom functionality).