I am tracking user changes to a sheet:
((Excel.DocEvents_Event)app.ActiveSheet).Change +=
new Excel.DocEvents_ChangeEventHandler(Event_WorksheetChange);
If I change a cell's value, then my function triggers:
private void Event_WorksheetChange(Excel.Range target)
{
// do something here
}
This works perfectly until I send/receive data over a TCP connection. Specifically, the event handler triggers every time if I do something that isn't TCP based. But once I send and receive messages, then eventually the event handler just stops triggering!
It's not an immediate thing in that I can send/receive a few messages while the handler still triggers. But after a dozen messages or so, the handler stops.
Also, I can "reactivate" the handler by calling the above logic to update Change
again. It's as if my handler had simply been removed and that I can re-add it.
I'm using Excel 365 and Visual Studio 2022.