Search code examples
c#visual-studioasynchronousmousewheelhelix-3d-toolkit

Helix Viewport continues zooming while paused at a breakpoint


I am running a Helix viewport and am catching a mousewheeled event with previewmousewheel to run a method. When debugging some changes I made to my methods I found out that when I set a breakpoint (anywhere between the catching of the mousewheeledevent and the subsequent applying of the zoom in the viewport) the amount of zoom from one detent of the mousewheel will increase continuously in proportion to the amount of time the program has been paused (basically the amount of time elapsed from the mousewheeledevent and the applying of the delta to the viewport). This makes debugging my changes the way I normally do seem not possible, though of course I can work around this.

The real problem is that now I realize that the zoom is completely erratic in this way, because some operations take longer than others between the event and the setting of the viewport, depending on what I'm doing.

This seems like a completely haphazard thing to have going on when I'm trying to make changes to a camera and completely control the camera behavior based on details specific to my program.

Is there any way to disable this from happening or mitigate it almost entirely?

The following code is a snippet from my program that seems to be the main driver of the issue, but I'm not sure I can just remove this method of keeping time in the program, because we definitely need an asynchronous timekeeper as far as I know.

    private async Task DoWorkAsyncInfiniteLoop()
    {
        while (true)
        {
            if (Run)
            {
                Time.timeElapsed += Time.runSpeed;
                Time.simTime += Time.runSpeed;
                updateAll();
            }
            // don't run again for at least 200 milliseconds
            await Task.Delay(Time.interval);
        }
    }

perhaps there is some lines I can add that will basically allow me to apply the zoom to the viewport without waiting for the await Task.Delay(Time.interval) line to run?

I must admit I'm not too clear on how that code works, but I do know that it stops at the await Task.Delay line before finally i hit "step into" (F11) one more time and it somehow just applies the monstrous zoom that was not wanted, without my seeing any code after that being run.

Any workarounds?


Solution

  • Try to set IsInertiaEnabled = false on viewport