02-01-2012 09:23 AM - edited 02-01-2012 09:26 AM
Where your code is located, and which application runs your code can be completely different things.
Listeners are an example of the Observer pattern, you register your Listeners to observe some action, and then the Application that actually initiates that action runs your Listener. So typically Listeners will run as a method in a process actually being run by another Application.
To give you another example of 'location of code does not have anything to do with who is running the code', think about all the Operating system processing that you do. You don't have classes called UiApplication or MainScreen in your Application do you? But the code that creates these will be being run as part of your Application.
But getting back to this problem, you need to move the data from the Listener (not your Application) into some processing that is being run in your Application.
The usual way is to use a Global Event. You use the Listener to capture the data you want, then fire a Global Event - this code will be performed in your Listening method, but NOT in your Application. You will have a Global Event Listener defined in your Application, the point here is that Global Events are actually run in your Application (on the Event Thread I think, but that detail is probably not relevant). So a Global Event listener has all the rights of your Application, so it can take the data that the Listener has captured for you and process it however it likes.
Hope this makes sense.
You need to create GUIDs that are unique to your Application. All Global Event Listeners get to see all Global Events. They will ignore ones that they don't recognize. So create a GUID (you probably have one anyway that you use for PersistentStore) and then use that to fire Global Events, knowing that the only listener that will understand this GUID is yours.
02-01-2012 09:27 AM