appccelerate / statemachine

A .net library that lets you build state machines (hierarchical, async with fluent definition syntax and reporting capabilities).
Apache License 2.0
481 stars 128 forks source link

PassiveStateMachine fails to execute events fired by different callers on their respective threads. Is this expected? #64

Open bhanugayam opened 4 years ago

bhanugayam commented 4 years ago

While one caller is executing an event if different fires event it is returned after adding it to queue. Meanwhile, the first caller tries to execute the newly added event in the queue before it returns.

This creates an issue with Stop behavior as while one caller is busy with executing events in the queue if other callers go on adding events to queue still the state machine will be running till all events have been executed.

This is different from the description given for PassiveStateMachine related to State Machine Events Execution.

ursenzler commented 4 years ago

If you call the same state machine instance from multiple threads, you must use the ActiveStateMachine. The PassiveStateMachine cannot handle multiple threads.

The ActiveStateMachine executes the events on its own thread and returns the call to Fire after the event was queued.