# Raising cross-patform events (.NET plugin vs Delphi host)

**URL:** https://talk.remobjects.com/t/raising-cross-patform-events-net-plugin-vs-delphi-host/14523
**Category:** Hydra
**Created:** [October 20, 2017, 2:04pm UTC](https://talk.remobjects.com/t/raising-cross-patform-events-net-plugin-vs-delphi-host/14523 "2017-10-20T14:04:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![eddiem](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/e/839c29/32.png) [@eddiem](https://talk.remobjects.com/u/eddiem)
#### Post date: [October 20, 2017, 2:04pm UTC](https://talk.remobjects.com/t/raising-cross-patform-events-net-plugin-vs-delphi-host/14523/1 "2017-10-20T14:04:27Z")

</div>

antonk,  
I’m sorry for posting on an old thread, but I’ve been searching for hours and this is the only hit I could find that was even close to the issue I’m having. I’m easily able to define the events in the interface, but I’m missing the step where that interface is consumed on the delphi side. I’ve created a Visual Plugin with two events:

```
event EventHandler LeftValueChanged;
event EventHandler RightValueChanged;

```

And imported that interface via the Hydra menu to generate the following code.

```
procedure add_LeftValueChanged(const value: EventHandler); safecall;
procedure remove_LeftValueChanged(const value: EventHandler); safecall;
procedure add_RightValueChanged(const value: EventHandler); safecall;
procedure remove_RightValueChanged(const value: EventHandler); safecall;

```

The problem I’m having is the Delphi compiler is giving me an error - Undeclared identifier ‘EventHandler’. What am I missing?

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [October 20, 2017, 6:01pm UTC](https://talk.remobjects.com/t/raising-cross-patform-events-net-plugin-vs-delphi-host/14523/2 "2017-10-20T18:01:20Z")

</div>

Hello

I’ve moved your post to a separate topic because the original thread you posted to was related to .NET host + .NET plugins pair.

This won’t work AS IS because Delphi knows notihng about the way .NET events are defined and managed:

```
event EventHandler LeftValueChanged;
event EventHandler RightValueChanged;

```

Instead you need to define method pair like

```
void AddListener(IListener value, Int32 eventKind);
void RemoveListener(IListener value, Int32 eventKind);

```

where eventKink is a code of the event you want to subscribe to/unsubscribe from.

IListener could be defined as

```
[Guid("EEE74183-854D-4A5F-AF2A-6A00AB10FB95")]
public interface IMessageProcessor: IHYCrossPlatformInterface
{
    void Execute();
}

```

So you just store reference to events executer in the **AddListener** method and remove it in the **RemoveListener** method.

Instead of raising an event you’ll need to call the **Execute** method of the listener instance.

Also please read this: [https://docs.hydra4.com/HowTos/PassingInterfacesBetweenHostAndPlugins/](https://docs.hydra4.com/HowTos/PassingInterfacesBetweenHostAndPlugins/)

Regards

---

<div class="post-metadata">

### Author: ![perceptionist](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/p/90ced4/32.png) [@perceptionist](https://talk.remobjects.com/u/perceptionist)
#### Post date: [January 19, 2018, 11:10pm UTC](https://talk.remobjects.com/t/raising-cross-patform-events-net-plugin-vs-delphi-host/14523/3 "2018-01-19T23:10:21Z")

</div>

If I had a very simple .net plugin. Say, it only has a button on it.

How, using this process, would I set up a Delphi host to respond to the button click.

When the button is pressed in the c# plug in, I want the Delphi host to ShowMessage(‘Clicked’)

I’ve been playing with the steps defined in this thread, but cannot figure it out. I’m every experienced with .Net, not so much with Delphi so that is where I need the assistance.

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [January 29, 2018, 9:52am UTC](https://talk.remobjects.com/t/raising-cross-patform-events-net-plugin-vs-delphi-host/14523/4 "2018-01-29T09:52:53Z")

</div>

Hello

Sorry for the belated answer. Take a look at this thread: [Need simple sample](https://talk.remobjects.com/t/need-simple-sample/8412/2)

This is exactly the sample you need.
