Hi normally I would do this with a Background Worker, but I would like to do it with C# Task instead, just to understand Task better.
The thing is that I have a class with the following properties
private int _number1;
public int Number1
{
get { return _number1; }
set { _number1 = value; OnPropertyChanged("Number1");}
}
private int _number2;
public int Number2
{
get { return _number2; }
set { _number2 = value; OnPropertyChanged("Number2");}
}
Please note that I use the INotifyPropertyChanged.
Number1 = Task<int>.Factory.StartNew(() => GenerateResult()).Result;
Number2 = Task<int>.Factory.StartNew(() => GenerateResult2()).Result;
The GenerateResult and GenerateResult2 are just dumme methods, who sleeps and then return a number.
How would I make this work Async? Since right now, GenerateResult2() is first called when GenerateResult() is finished.
I need it to be able work Async, since I have no idea of when each task is going to finish or even if its going to finish.