Hi !
Well... I do this to add a function on a event:
dataRecebe.dadosRecebidos += new dataRecebe.delDadosRecebidos(atualiza_ligado);
and this to take off..
dataRecebe.dadosRecebidos -= new dataRecebe.delDadosRecebidos(atualiza_ligado);
Correct !
But if I add many function for determinate event... I will always do "... -= ..." don't have another way
Hug,
Joao

Problem with event...
imanish11111
willthiswork89
Hi,
the only way to remove an event is using the -= syntax. However if you define you own event i.e.
event X
{
add{...}
remove{...}
}
You can get access the the underlying delegate and then clear out all of the event listeners by resetting the delegate to null.
Mark.
Michael-Renger
Hi,
you will have to define the event manually, i.e.:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Test t = new Test();
t.MyEvent += new Test.MyEventHandler(t_MyEvent);
t.ClearAllListeners();
}
static void t_MyEvent()
{
}
}
class Test
{
public delegate void MyEventHandler();
private MyEventHandler myEventHandler = null;
public event MyEventHandler MyEvent
{
add
{
myEventHandler = (MyEventHandler)Delegate.Combine(myEventHandler, value);
}
remove
{
myEventHandler = (MyEventHandler)Delegate.Remove(myEventHandler, value);
}
}
public void ClearAllListeners()
{
if (myEventHandler != null)
{
myEventHandler = null;
}
}
}
}
Mark.
JuKiM
Obs.: To invoke the event: myEventHandler.invoke();