We have some models that get data using tasks and I've been doing some testing and noticed that it seems like UI (STA Thread) elements can be modified by background tasks. This was not previously the case. Has something changed with VS 2017 or .net 4.7?
public class FancyModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _state;
public FancyModel(ILongRunningOperation opGetter)
{
Task.Run(() =>
{
State = opGetter.LongRunningOperation();
});
}
public string State
{
get { return _state; }
set {
_state = value;
PropertyChanged?.Invoke(this, nameof(State));
}
}
}