Question

Locked

Event Handling

By Soundbomber ·
Does anyone know of a method of handling events between different applications? For example, two applications are running (possibly as services), an event is fired in app1, the event is handled in app2. I am working in windows using vb.net. I must be able to debug the code also.
Any suggestions?
Thanks in advance.

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Now there's a tin of worms.

by Tony Hopkinson In reply to Event Handling

You just multi-threaded.
One of the simplest mechanisms is to send a windows message from one app to the other.
However, is the processing asynchronous, if not can you afford to block while waiting for the event to be handled. Even if this event and handle is aynchronous, is the data being processes used elsewhere, should that be blocked.

You'll probably end up with a better design if you move the common stuff into it's own thread/process/service, certainly it will be far easier to think through potential conflicts in accessing common resources.

Collapse -

Tell me about it!

by Soundbomber In reply to Now there's a tin of worm ...

I'm not sure yet whether the processing will be asynchronous or not (one of the apps is 3rd party), i'm still at the early stages but my guess is synchronous. I've toyed around with a 'middle level' process that both apps can bounce calls to and from, but the biggest hurdle I have is trying to get a handle on one applications dll from another whilst debugging the code from Visual Studio. I don't think I'm explaining this too well but my ideal scenario is this: The 3rd party app(app1) is running, my app(app2) is running in debug mode. An event is fired from app1, app2 handles event fired from app1.

Collapse -

The third party app is already firing events?

by Tony Hopkinson In reply to Tell me about it!

How ever it does that will dictate how you handle them.

Collapse -

Re: Event Handling

by jason.donnell In reply to Event Handling

There may be a better way to do this, but the initial solution that came to my mind was to simply monitor a value in the registry. This value would represent (for App 2) the event that occurred in App 1. If you have never done this before, reading/writing to the windows registry in VB.Net is very easy.

I am unaware of a method for communicating directly between two applications. Maybe someone else has a better solution to this issue??

Collapse -

That usually sort of works

by Tony Hopkinson In reply to Re: Event Handling

but it's not transactional and it's not thread safe, and use of the registry is quite rightly dying a miserable death. As short term patch, it may be a goer, but it's as future proof asa chocolate radiator.

The default slightly less easy but doable mechanism for communicating between processes are the sendmessage and postmessage APIs. As soon as you get into this sort of thing, tubular invertebrates will swarm all over your desk though.

Collapse -

Sounds like a job for Scripting(maybe)

by toms45 In reply to Event Handling

Does App1 fire an event that the event log would capture? If so, your app2 in debug mode could run a WMI script to monitor the event log. Just a thought since I've gotten heavily into scripting for a project at work.

Collapse -

Event Handling

by Soundbomber In reply to Event Handling

I have got the 'cooperation' of the developers of app1 and am hoping to get them to sign on to this 'joint event handling', whatever that turns out to be. I am hoping that we can find a mutual solution that doesn't involve them changing too much code as their app is well established already. Just sounding out for ideas really.

Collapse -

You need a notification system

by MadestroITSolutions In reply to Event Handling

From what I can understand, there is an application made by someone else that you are basically trying to "hook to" in a sense since you want to be able to "react" to some sort of event taking place in that app.

If that is the case, then obviously you need some sort of notification system so that app1 can somehow signal app2.

There are tons of ways of achieving this. It really is up to your imagination. It also depends a lot on the transactional requirements (atomic unit) and the level of error handling you are going to need.

However, if you are only interested in one way communication (from app1 to app2) and want as less change in app1 as possible, then I would suggest you monitor a folder and have app1 write small event files that your service will process. This should be fairly simple to implement for app1 developers and it is flexible enough as you can send any information you want concerning the event in those files. Your app can then pick up the file, process it and discard it.

You should also consider concurrency issues when playing with applications that fire events.

Hope that helps.

Good luck!

Collapse -

Thanks

by Soundbomber In reply to Event Handling

Thank you all for your help.
There's food for thought.

Collapse -

Thanks

by Soundbomber In reply to Event Handling

Thank you all for your help.
There's food for thought.

Back to Software Forum
10 total posts (Page 1 of 1)  

Related Discussions

Related Forums