In Viewmodel, I want to track the status of async call. Suppose I have two async calls in viewmodel, I want to track when all async call done. What I did as below: Set to private var to track each async calls:
private bool _isDone1 = false;
private bool _isDone2 = false;
Set one property like:
private bool _isDone;
public bool IsDone
{
get { return this._isDone1&&this._isDone2; }
set
{
if (this._isDone != value)
{
this._isDone = value;
if(this._isDone)
{
// done somting here when all async call done
}
this.RaisePropertyChanged("IsDone");
}
}
}
In completed event for each async call, set code like: For call 1:
_isDone1 = true;
this.RaisePropertyChanged("IsDone");
For call 2:
_isDone2 = true;
this.RaisePropertyChanged("IsDone");
Then I run the app, It seems code for IsDone never be touched. How to reslove this problem or any better solution for this case?