Raise an event in C # from an external application?

Is there a way to raise an event in C # from an external application? In particular, from Ruby? I need something to happen in C # from a rails application.

+6
c # ruby events ruby-on-rails
source share
4 answers

I assume that by “external application” you mean something that is outside the scope of the C # code process space. Also, I assume that you do not mean C # events that are not a concept that exists outside of the .NET implementation domain - they are not accessible from outside the code.

So the general answer to this question is “yes, it’s possible”, but since you are essentially trying to send notifications about the interprocess process, you will need to use some kind of IPC Engine .

.NET has a rich API for IPC implementation, from named pipes to DCOM, to low-level network protocols such as TCP / IP. Which approach you use depends on the environment in which this process should interact (on one machine, through machines on an intranet, over the Internet, etc.). It will also depend on what information you exchange and how much effort you are willing to spend. For .NET 3.5 applications, you can usually find a supported implementation using WCF as a unifying environment .

Obviously, it all depends on your ability to modify the implementation (read the source code) of the .NET application that you are trying to raise an event inside. If you cannot do this and there is no existing IPC mechanism in this code, you are probably stuck.

UPDATE: in response to your comment:

What would you recommend with a priority of ease and time. Both applications run on the same computer, and I write them to both

I would consider using Named Pipes . Named pipes are originally a Unix concept, but they are also available on Windows. They have a simple programming interface (they are similar to working with files) and do not require much for use in a single-computer scenario.

On the Ruby side (which I'm least familiar with), here are a few links you might find useful:

On the .NET side, here are some relevant links for more details:

+6
source share

An obvious solution would be to use a network message. Either a short TCP / IP connection, or, especially if both applications are on the same host, is a simple UDP packet.

A C # application will accept connections (if TCP), read events from a socket, and finally process them.

+1
source share

To expand Martin's answer, you can consider a messaging protocol with libraries available in both target languages. Something like Stomp comes to mind.

0
source share

Perhaps you can do something with message queues, especially with support for multiple platforms and langauges such as ActiveMQ . I would suggest that he will have the opportunity to add a handler for the received message so that you can receive asynchronous delivery.

0
source share

All Articles