I have a stateMachine
where I need to download a huge amount of data in the background at State.LoadingOrderInfos
. While my application is downloading the stuff (in the background), the operator should work on and go through the next states
.
At State.InsertPcbs
I need the downloaded data.
In short words. I want to call LoadECMDataAsync
when entering State.LoadingOrderInfos
and it should not disturb the normal workflow.
_machine.Configure(State.LoadingOrderInfos)
.Ignore(Trigger.WtPresent)
.Ignore(Trigger.WtNotPresent)
.SubstateOf(State.CanLogOut)
.Permit(Trigger.OrderLoadingFailed, State.OrderNotSelected)
.Permit(Trigger.OrderLoadingComplete, State.OrderCheckSetup)
.OnEntry(() =>
{
IsLoading = true;
Wt = null;
})
// Is this the way how to do it?
.OnEntry(() =>
{
LoadECMDataAsync();
})
.OnActivate(async () =>
{
if (await _LoadOrderInfos().ConfigureAwait(true))
{
_machine.Fire(Trigger.OrderLoadingComplete);
}
else
{
_machine.Fire(Trigger.OrderLoadingFailed);
}
})
.OnExit(() => IsLoading = false);