Vycka / LoadRunner

Load-testing framework for writing load/stress test scenarios in c#
GNU General Public License v3.0
20 stars 5 forks source link

LoadRunnerUi validator async/await deadlock #2

Closed Vycka closed 6 years ago

Vycka commented 7 years ago

Running validation on ILoadTestScenario containing TPL things with await or .Result, will deadlock LoadRunnerUi

Vycka commented 7 years ago

MyEventHandler synchronously calls InnocentLookingClass constructor, which invokes DoSomeLengthyStuffAsync, which in turn asynchronously invokes SomeOtherLengthyStuffAsync. The execution of the latter method starts; at the same time the main thread blocks at Wait until DoSomeLengthyStuffAsync completes without giving control back to the main message loop.

Eventually SomeOtherLengthyStuffAsync completes and posts a message to the message queue implying that the execution of DoSomeLengthyStuffAsync can continue. Unfortunately, the main thread is waiting for that method to complete instead of processing the messages, and will therefore never trigger it to continue, hence waiting indefinitely.

http://www.dotnetcurry.com/csharp/1307/async-await-asynchronous-programming-examples

Vycka commented 6 years ago

Easier fix? https://github.com/Vycka/LoadRunner/blob/v0.8/src/Viki.LoadRunner.Tools/Windows/LoadRunnerUi.cs#L165