Friday, 5 February 2016

Parallel Programming-----Day 1(6th Feb 2016)

Hello Techies,

"One of the rule in .Net is that the only thread that is allowed to update or touch the user interface is the thread that created it. If we try to update the user interface with a thread that is not UI thread than application will crash. In order to circumvent the problem Approach number one will be to run this task in the context of the user interface thread but this approach will again impacts the responsiveness as the code will be executing on the UI thread."


 

Another approach is use the context only when updation is required not for the entire duration of the long running task. See below code t2 will start only when t1 gets completed. Thus once we have all the computation done so as to update on UI we will do that in task t2 and using context of UI thread.


 Enjoy and Share your learning.

No comments:

Post a Comment