Re: Interfaces and Events
- From: Andy <me@xxxxxxxxxxx>
- Date: Tue, 21 Feb 2006 19:08:47 +0100
Bob Jones wrote:
Jon,
That's how I originally set the interface up. However, I found that I could not figure out how Program C was supposed to cosume those events. The events are raised by Class B and need to be consumed by Program C.
My understanding is that Class B need to implement the delegates and Program C should consume those events. How can I make this situation work?
Regards
<snip />
Not sure if this is what you are looking for:
namespace ConsoleApplication14
{
delegate void FooHandler();
interface IXox
{
event FooHandler Foo;
}
class Lulli : IXox
{
public event FooHandler Foo;
public void OnFoo()
{
if (Foo != null)
Foo();
}
}
class Program
{
static void Main(string[] args)
{
IXox xox = new Lulli();
xox.Foo += new FooHandler(xox_Foo);
// Demo: Raise the event!
((Lulli)xox).OnFoo();
}
static void xox_Foo()
{
Console.WriteLine("Foo called.");
}
}
}
Or do you mean the C is really another different programm? Then you have to do some sort of IPC, e.g. remoting.
HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
.
- Follow-Ups:
- Re: Interfaces and Events
- From: Bob Jones
- Re: Interfaces and Events
- References:
- Interfaces and Events
- From: goodoldave
- Re: Interfaces and Events
- From: Jon Skeet [C# MVP]
- Re: Interfaces and Events
- From: Bob Jones
- Interfaces and Events
- Prev by Date: Re: Interfaces and Events
- Next by Date: Re: Interfaces and Events
- Previous by thread: Re: Interfaces and Events
- Next by thread: Re: Interfaces and Events
- Index(es):
Relevant Pages
|