Hello.
There is a State Machine with two Transitions in the same function.
static readonly object _object = new object();
lock (_object)
{
// I want Host received the event of SMTrans01 first .
Obj.StateMachine.Send((int)MyStateMachine.EventType.SMTrans01, new object[2] { Obj, MyStateMachine.EventType.SMTrans01 });
}
lock (_object)
{
// And then I want Host received the event of SMTrans02.
Obj.StateMachine.Send((int)MyStateMachine.EventType.SMTrans02, new object[2] { Obj, MyStateMachine.EventType.SMTrans02 });
}
I implemented my state machine code as above. I am not sure I understand Lock
statement correctly or not?
I need the events followed the the right order (Host received SMTrans01 first, and then host received SMTrans02 event).
After testing I found sometime host will receive the SMTrans02 event first. Looks like Lock
statement not work. I don't know why.
Are there any good methods to approach it?