add:WinRT墨迹识别
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -39,6 +40,9 @@ namespace Ink_Canvas
|
||||
/// </summary>
|
||||
private List<Circle> circles = new List<Circle>();
|
||||
|
||||
/// <summary>串行执行墨迹转形状(尤其 WinRT 异步延后),避免多笔 BeginInvoke 交错修改 newStrokes。</summary>
|
||||
private static readonly SemaphoreSlim InkToShapeSerial = new SemaphoreSlim(1, 1);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -390,6 +394,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
async Task InkToShapeProcessCoreAsync()
|
||||
{
|
||||
await InkToShapeSerial.WaitAsync().ConfigureAwait(true);
|
||||
try
|
||||
{
|
||||
newStrokes.Add(e.Stroke);
|
||||
@@ -713,6 +718,10 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
finally
|
||||
{
|
||||
InkToShapeSerial.Release();
|
||||
}
|
||||
}
|
||||
|
||||
void InkToShapeProcess()
|
||||
@@ -730,7 +739,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex);
|
||||
}
|
||||
}), DispatcherPriority.Background);
|
||||
}), DispatcherPriority.Normal);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user