Skip to content

Commit

Permalink
Getting TargetInvocationException and NullReferenceException sometime…
Browse files Browse the repository at this point in the history
…s when using code like this:

for (let propertyName in KeyboardKey) {
  (function (that) {
    Wait(function () {
      Print(that)
    }, 1)
  })(propertyName);
}
  • Loading branch information
luttje committed Jun 29, 2022
1 parent 83bd1fe commit cdda97a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion KeyToJoy/Mapping/Actions/Logic/WaitAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public WaitAction(string name, string description)
/// </markdown-doc>
/// <summary>
/// Wait for the specified duration in milliseconds, then execute the callback
///
/// <strong>Note: There are issues with this function I have yet to fix. It may not work as expected sometimes!</strong>
/// </summary>
/// <param name="callback">Function to execute</param>
/// <param name="waitTime">Time to wait (in milliseconds)</param>
Expand All @@ -44,7 +46,7 @@ public void ExecuteForScript(Action callback, long waitTime)
var task = Task.Run(async () =>
{
await Task.Delay(WaitTime);
callback();
callback.DynamicInvoke();
});
}

Expand Down

0 comments on commit cdda97a

Please sign in to comment.