I have to refactor a complex C# app (many dialogs, mixed logic and so on).
There is a part managing the communication with special hardware equipments (sending commands and receive data via asynchronous c# callbacks). The code is "spaghetti" with mixed UI/Logic/Communication/etc and my task is to split the layers in a DDD sense.
So, to which layer belongs a callback driver routine?
The callbacks are creating "bubbles" in the system, up to the UI layer and because of this I cannot enforce the essential principle that any element of a layer depends only on other elements in the same layer or on elements of the layers "beneath" it.