feat(lmxproxy): add STA thread with message pump for MxAccess COM callbacks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ namespace ZB.MOM.WW.LmxProxy.Host.MxAccess
|
||||
/// <summary>
|
||||
/// Subscribes to value changes for the specified addresses.
|
||||
/// Stores subscription state for reconnect replay.
|
||||
/// COM calls dispatched via Task.Run.
|
||||
/// COM calls dispatched on the dedicated STA thread.
|
||||
/// </summary>
|
||||
public async Task<IAsyncDisposable> SubscribeAsync(
|
||||
IEnumerable<string> addresses,
|
||||
@@ -25,7 +25,7 @@ namespace ZB.MOM.WW.LmxProxy.Host.MxAccess
|
||||
|
||||
var addressList = addresses.ToList();
|
||||
|
||||
await Task.Run(() =>
|
||||
await _staThread.RunAsync(() =>
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace ZB.MOM.WW.LmxProxy.Host.MxAccess
|
||||
_storedSubscriptions[address] = callback;
|
||||
}
|
||||
}
|
||||
}, ct);
|
||||
});
|
||||
|
||||
Log.Information("Subscribed to {Count} tags", addressList.Count);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ZB.MOM.WW.LmxProxy.Host.MxAccess
|
||||
{
|
||||
var addressList = addresses.ToList();
|
||||
|
||||
await Task.Run(() =>
|
||||
await _staThread.RunAsync(() =>
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace ZB.MOM.WW.LmxProxy.Host.MxAccess
|
||||
|
||||
Log.Information("Recreating {Count} stored subscriptions after reconnect", subscriptions.Count);
|
||||
|
||||
await Task.Run(() =>
|
||||
await _staThread.RunAsync(() =>
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user