I am newer to Multi Threaded applications in C#. While i am working on it i have learnt about UI Thread which take care of application UI. Now am in a bit confusion in What to do with UI Thread and What should not do.
Task.Factory.StartNew(() =>
{
try
{
device.Capture(); // capturing data from a I/O device
}
catch (Exception ex)
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
{
show_error(ex.Message);
}));
}
});
From the code example every I/O or DB access or Long Runner tasks should be done by a Worker Thread and the UI should be updated by a UI Thread. Above this example I want to know what can be done efficiently by a UI Thread and what are not?
Update:
Indeed let me given a example of using a C# Timer and DispatcherTimer. Timer runs on a different thread and DispatcherTimer uses UI Thread. By this DispatcherTimer may a hangs while the UI Thread is Busy. So where this DispatcherTimer can be used efficiently which runs on UI Thread ?