ApiEventManager Rework #1004

Open
opened 2026-01-29 16:54:24 +00:00 by claunia · 0 comments
Owner

Originally created by @softworkz on GitHub (Nov 9, 2025).

Figured out the problem

internal static void AddEvent(string eventName, object id, Action callback, Action value)
{
    var call = (Action)events.GetOrAdd(eventName, callback);
    if (call == null)
    {
        BridgeConnector.Socket.On(eventName + id, () =>
        {
            ((Action)events[eventName])();
        });
        BridgeConnector.Socket.Emit($"register-{eventName}", id);
    }
    
    call += value;
    events[eventName] = call;
}

@softworkz could you advise whether it requires any locks and if so where.

Originally posted by @agracio in https://github.com/ElectronNET/Electron.NET/issues/913#issuecomment-3508416476

Originally created by @softworkz on GitHub (Nov 9, 2025). Figured out the problem ```cs internal static void AddEvent(string eventName, object id, Action callback, Action value) { var call = (Action)events.GetOrAdd(eventName, callback); if (call == null) { BridgeConnector.Socket.On(eventName + id, () => { ((Action)events[eventName])(); }); BridgeConnector.Socket.Emit($"register-{eventName}", id); } call += value; events[eventName] = call; } ``` @softworkz could you advise whether it requires any locks and if so where. _Originally posted by @agracio in https://github.com/ElectronNET/Electron.NET/issues/913#issuecomment-3508416476_
claunia added the enhancement label 2026-01-29 16:54:24 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1004