delegate not removed from invoicationlist

  • Thread starter Thread starter Bart
  • Start date Start date
B

Bart

Hi, what is wrong with following code:
try
{
subm.EndInvoke(ar);
}
catch (System.Net.WebException ex)
{
try
{
System.Delegate.Remove(Submission, subm); --> no
exception is thrown, but delegate 'subm' is not removed from 'submission'

}
catch (Exception)
{
throw;
}
}

Thanks
 
Hi, what is wrong with following code:
try
{
subm.EndInvoke(ar);
}
catch (System.Net.WebException ex)
{
try
{
System.Delegate.Remove(Submission, subm); --> no
exception is thrown, but delegate 'subm' is not removed from 'submission'

}
catch (Exception)
{
throw;
}
}

Delegates are immutable. Calling Remove returns a *new* delegate
instance.

You want:

subm -= Submission;

which is shorthand for:

subm = Delegate.Remove(Submission, subm);

Jon
 
Hi Jon,

I suppose you mean
Submission -= subm ;
I tried that also, but with the same result.
Any idea?
Bart
 
Back
Top