Last Updated:
06 Oct 2025 11:20
by Martin Ivanov
VirtualKeyboard: Improve the task cancelation behavior in the Task started in the internal StartTrackingSystemCulture method to avoid unobserved OperationCanceledException
RadVirtualKeyboard starts a new Task which constantly checks the system culture and synchronizes this with the culture of the control. When the control gets unloaded or when the SynchronizeCultureWithSystem property is set to False, the Task's thread is stopped using the Cancel method of the associated CancellationToken, along with the ThrowIfCancellationRequested method.
This throws an OperationCanceledException, which is the expected behavior to signal that the thread was canceled. However, the exception is marked as unobserved, which throws the TaskScheduler.UnobservedTaskException static event. This doesn't cause problems in the control or the host application, but the RadVirtualKeyboard can handled it better, so the exception is not marked as unobserved.