Run any WPF application on a computer which is currently has a high CPU usage, if you keep plugging and unplugging a USB HID tablet device at the same time, the WPF applications will stop responding to touches and only respond to mouse.
The requirements:
- Run any WPF application
- Keep plugging and unplugging a USB HID tablet device
- Make a high CPU usage
My question:
Is there any thorough way for us non-Microsoft developers do to fix this touch failure?
I've posted the preliminary analysis of the touch failure here:
This article is a bit long for StackOverflow, so I only mention some conclusion here:
- There may be a deadlock for GetPenEventMultipleposted below.
- There may be other thread-safety issues of GetTabletInfoHelper.
The code below is from .NET Framework and I simplified them for easier understanding:
// PenThreadWorker.ThreadProc
while(There are two loops in real)
{
    // The `break` below only exit one loop, not two.
    if (this._handles.Length == 1)
    {
        if (!GetPenEvent(this._handles[0], otherArgs))
        {
            break;
        }
    }
    else if (!GetPenEventMultiple(this._handles, otherArgs))
    {
        break;
    }
    // Other logics.
}
// WorkerOperationGetTabletsInfo.OnDoWork
try
{
    _tabletDeviceInfo = PenThreadWorker.GetTabletInfoHelper(pimcTablet);
}
catch(COMException)
{
    _tabletDevicesInfo = new TabletDeviceInfo[0];
}
catch(ArgumentException)
{
    _tabletDevicesInfo = new TabletDeviceInfo[0];
}
// Other exception handling.
 
     
    