Thursday 19 September 2013

set a property value from object in task

set a property value from object in task

I have an object called Settings. it has a property called BusyDoingAction
of type bool
public class Settings : ObservableObject
{
private bool busyDoingAction;
public bool BusyDoingAction
{
get { return this.busyDoingAction; }
set
{
this.busyDoingAction= value;
OnPropertyChanged(() => BusyDoingAction);
}
}
I have another class called FileAdding,
private readonly string[] files;
private bool busy;
public FileAdding(string[] files, bool busyAction)
{
this.files = files;
this.busy= busyAction;
}
now, in my ViewModel I have the following:
var fileAdding = new FileAdding(files, Settings.BusyDoingAction);
if (!fileAdding.Initialize())
return;
Task<bool>.Factory.StartNew(() =>
{
fileAdding.Execute(CToken);
return fileAdding.Deinitialize();
}, CToken);
}
and in the FileAdding Initialize() function I have:
public bool Initialize()
{
busy = true;
return true;
}
public bool Deinitialize()
{
busy = false;
return true;
}
the problem is: the BusyDoingAction is not changing in the FileAdding and
iam not getting any value changed notification for that property ..
The Property is bound to the mainGrid in my application, and iam using it
to detect whether the application is busy and enable/disable the grid
depending on the value of BusyDoingAction
I don't know what iam doing wrong, but I need to set the property value of
BusyDoingAction in that busyDoingAction.Intialize/Deinitialize function ..
any help is really appreciated ..

No comments:

Post a Comment