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

fix #42 AsyncActiveStateMachine.Fire never completes #49

Closed wtjerry closed 4 years ago

wtjerry commented 4 years ago

To use RunContinuationsAsynchronously we need at least version 1.3 of .Net standard. Internal behaviour change in case of a single thread: before this fix only ever one event will be enqueued before it is processes. That was because when the workerCompletionSource was set, the awaiting code for the same Task continued synchronously and immediately processed the Event. Only after the processing was done, another event could be enqueued. After this fix it is possible that multiple events will be enqueued before the first one will be processed. Because the awaiting task will continue asynchronously.