mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-14 13:07:18 +00:00
refactor: Refactor DeviceManager and related classes to improve thread safety and performance
- Replaced CCriticalSection with lock statements in DeviceManager for better thread management. - Updated AddDevice and RemoveDevice methods to use Monitor for locking. - Enhanced event handling for device activation and registration. - Modified FileIO class to utilize Task for asynchronous file operations instead of CrestronInvoke. - Improved feedback mechanisms in FeedbackBase and SystemMonitorController using Task.Run. - Refactored GenericQueue to remove Crestron threading dependencies and utilize System.Threading. - Updated BlueJeansPc and VideoCodecBase classes to use Task for asynchronous operations. - Cleaned up unnecessary critical sections and improved code documentation across various files.
This commit is contained in:
parent
426ef4ad6b
commit
346a5e9e57
23 changed files with 998 additions and 912 deletions
|
|
@ -103,7 +103,7 @@ namespace PepperDash.Essentials
|
|||
/// </summary>
|
||||
public MobileControlWebsocketServer DirectServer => _directServer;
|
||||
|
||||
private readonly CCriticalSection _wsCriticalSection = new CCriticalSection();
|
||||
private readonly object _wsCriticalSection = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the SystemUrl
|
||||
|
|
@ -206,14 +206,14 @@ namespace PepperDash.Essentials
|
|||
//_receiveQueue = new ReceiveQueue(key, ParseStreamRx);
|
||||
_receiveQueue = new GenericQueue(
|
||||
key + "-rxqueue",
|
||||
Crestron.SimplSharpPro.CrestronThread.Thread.eThreadPriority.HighPriority,
|
||||
System.Threading.ThreadPriority.Highest,
|
||||
25
|
||||
);
|
||||
|
||||
// The queue that will collect the outgoing messages in the order they are received
|
||||
_transmitToServerQueue = new GenericQueue(
|
||||
key + "-txqueue",
|
||||
Crestron.SimplSharpPro.CrestronThread.Thread.eThreadPriority.HighPriority,
|
||||
System.Threading.ThreadPriority.Highest,
|
||||
25
|
||||
);
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ namespace PepperDash.Essentials
|
|||
|
||||
_transmitToClientsQueue = new GenericQueue(
|
||||
key + "-clienttxqueue",
|
||||
Crestron.SimplSharpPro.CrestronThread.Thread.eThreadPriority.HighPriority,
|
||||
System.Threading.ThreadPriority.Highest,
|
||||
25
|
||||
);
|
||||
}
|
||||
|
|
@ -1811,10 +1811,8 @@ namespace PepperDash.Essentials
|
|||
|
||||
private void ConnectWebsocketClient()
|
||||
{
|
||||
try
|
||||
lock (_wsCriticalSection)
|
||||
{
|
||||
_wsCriticalSection.Enter();
|
||||
|
||||
// set to 99999 to let things work on 4-Series
|
||||
if (
|
||||
(CrestronEnvironment.ProgramCompatibility & eCrestronSeries.Series4)
|
||||
|
|
@ -1843,10 +1841,6 @@ namespace PepperDash.Essentials
|
|||
|
||||
TryConnect();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_wsCriticalSection.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
private void TryConnect()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue