diff --git a/ScpCleanWipe/Properties/CommonInfo.cs b/ScpCleanWipe/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpCleanWipe/Properties/CommonInfo.cs +++ b/ScpCleanWipe/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpControl/Bluetooth/BthDevice.cs b/ScpControl/Bluetooth/BthDevice.cs index 884e7596..0aef1f39 100644 --- a/ScpControl/Bluetooth/BthDevice.cs +++ b/ScpControl/Bluetooth/BthDevice.cs @@ -3,6 +3,7 @@ using System.Net.NetworkInformation; using System.Reactive.Concurrency; using System.Reactive.Linq; +using System.Threading.Tasks; using ScpControl.ScpCore; using ScpControl.Shared.Core; using ScpControl.Sound; @@ -22,6 +23,8 @@ public partial class BthDevice : BthConnection, IDsDevice private IDisposable _outputReportTask; + private readonly TaskQueue _inputReportQueue = new TaskQueue(); + #endregion #region Protected fields @@ -187,9 +190,13 @@ public virtual void Completed() public event EventHandler HidReportReceived; - protected virtual void OnHidReportReceived(ScpHidReport report) + protected void OnHidReportReceived(ScpHidReport report) { - if (HidReportReceived != null) HidReportReceived(this, report); + _inputReportQueue.Enqueue(() => Task.Run(() => + { + if (HidReportReceived != null) + HidReportReceived.Invoke(this, report); + })); } #endregion diff --git a/ScpControl/Properties/CommonInfo.cs b/ScpControl/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpControl/Properties/CommonInfo.cs +++ b/ScpControl/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpControl/ScpControl.csproj b/ScpControl/ScpControl.csproj index 22354af6..b912712a 100644 --- a/ScpControl/ScpControl.csproj +++ b/ScpControl/ScpControl.csproj @@ -23,7 +23,7 @@ AssemblyVersionAttribute - 1.6.210.15353 + 1.6.211.15353 true @@ -225,6 +225,7 @@ + diff --git a/ScpControl/Usb/UsbDevice.cs b/ScpControl/Usb/UsbDevice.cs index 167bb524..af9ccc53 100644 --- a/ScpControl/Usb/UsbDevice.cs +++ b/ScpControl/Usb/UsbDevice.cs @@ -27,6 +27,8 @@ public partial class UsbDevice : ScpDevice, IDsDevice private IDisposable _outputReportTask; + private readonly TaskQueue _inputReportQueue = new TaskQueue(); + #endregion #region Private methods @@ -80,9 +82,13 @@ private void HidWorker(object o) public event EventHandler HidReportReceived; - protected virtual void OnHidReportReceived(ScpHidReport report) + protected void OnHidReportReceived(ScpHidReport report) { - if (HidReportReceived != null) HidReportReceived(this, report); + _inputReportQueue.Enqueue(() => Task.Run(() => + { + if (HidReportReceived != null) + HidReportReceived.Invoke(this, report); + })); } #endregion diff --git a/ScpControl/Utilities/TaskQueue.cs b/ScpControl/Utilities/TaskQueue.cs new file mode 100644 index 00000000..3a50e711 --- /dev/null +++ b/ScpControl/Utilities/TaskQueue.cs @@ -0,0 +1,34 @@ +using System; +using System.Threading.Tasks; + +namespace ScpControl.Utilities +{ + /// + /// A non-blocking event handling queue. + /// + /// http://stackoverflow.com/a/32993768/490629 + public class TaskQueue + { + private Task _previous = Task.FromResult(false); + private readonly object _key = new object(); + + public Task Enqueue(Func> taskGenerator) + { + lock (_key) + { + var next = _previous.ContinueWith(t => taskGenerator()).Unwrap(); + _previous = next; + return next; + } + } + public Task Enqueue(Func taskGenerator) + { + lock (_key) + { + var next = _previous.ContinueWith(t => taskGenerator()).Unwrap(); + _previous = next; + return next; + } + } + } +} diff --git a/ScpDebugInfoCollector/Properties/CommonInfo.cs b/ScpDebugInfoCollector/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpDebugInfoCollector/Properties/CommonInfo.cs +++ b/ScpDebugInfoCollector/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpDriverInstaller/Properties/CommonInfo.cs b/ScpDriverInstaller/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpDriverInstaller/Properties/CommonInfo.cs +++ b/ScpDriverInstaller/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpGamepadAnalyzer/Properties/CommonInfo.cs b/ScpGamepadAnalyzer/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpGamepadAnalyzer/Properties/CommonInfo.cs +++ b/ScpGamepadAnalyzer/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpMonitor/Properties/CommonInfo.cs b/ScpMonitor/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpMonitor/Properties/CommonInfo.cs +++ b/ScpMonitor/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpPair/Properties/CommonInfo.cs b/ScpPair/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpPair/Properties/CommonInfo.cs +++ b/ScpPair/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpProfiler/Properties/CommonInfo.cs b/ScpProfiler/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpProfiler/Properties/CommonInfo.cs +++ b/ScpProfiler/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpServer/Properties/CommonInfo.cs b/ScpServer/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpServer/Properties/CommonInfo.cs +++ b/ScpServer/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpService/Properties/CommonInfo.cs b/ScpService/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpService/Properties/CommonInfo.cs +++ b/ScpService/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpSettings/Properties/CommonInfo.cs b/ScpSettings/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpSettings/Properties/CommonInfo.cs +++ b/ScpSettings/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file diff --git a/ScpXInputBridge/Properties/CommonInfo.cs b/ScpXInputBridge/Properties/CommonInfo.cs index 710c3dbb..71b47106 100644 --- a/ScpXInputBridge/Properties/CommonInfo.cs +++ b/ScpXInputBridge/Properties/CommonInfo.cs @@ -12,5 +12,5 @@ [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.6.210.15353")] -[assembly: AssemblyFileVersion("1.6.210.15353")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.211.15353")] +[assembly: AssemblyFileVersion("1.6.211.15353")] \ No newline at end of file