A ui elememt can only be accessed by one UI Thread. CheckBox Requires UI Thread and your timer runs on different thread. Simple code to use Dispatcher
if (client.Connected == true)
{
Dispatcher.Invoke(()=> {
// Code causing the exception or requires UI thread access
CheckBox.IsChecked =true;
});
}
OR
if (client.Connected == true)
{
Dispatcher.Invoke(new Action(()=> {
// Code causing the exception or requires UI thread access
CheckBox.IsChecked =true;
}));
}
if you receive error An object reference is required for the non-static field, method, or property
then use this
Application.Current.Dispatcher.Invoke(() =>
{
// Code causing the exception or requires UI thread access
});