M
Mike Thompson
The language for this question is C#.
I have a class named client which derives from IDisposable; it contains
several event handlers.
In another class, I create a static instance of the client class and
subscribe to two of its events, using standard += syntax, for example:
client.Error += new EventHandler<client.ErrorEventArgs>(client_ErrorEvents);
Later in code, I unsubscribe from the events (for example client.Error -=
client_ErrorEvents, and dispose of the instance of the client class by
calling its Dispose method:
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
Now, without closing the main form, I create a new instance of the client
class (this is a button click event). Its methods and properties are
available again as before, but its event handers do not respond to any
events this time, although they responded the first time.
This a multithreaded environment, but I don't think that is causing any
problems in this case.
I hope this is enough code to illustrate the problem. Any ideas would be
most appreciated.
I have a class named client which derives from IDisposable; it contains
several event handlers.
In another class, I create a static instance of the client class and
subscribe to two of its events, using standard += syntax, for example:
client.Error += new EventHandler<client.ErrorEventArgs>(client_ErrorEvents);
Later in code, I unsubscribe from the events (for example client.Error -=
client_ErrorEvents, and dispose of the instance of the client class by
calling its Dispose method:
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
Now, without closing the main form, I create a new instance of the client
class (this is a button click event). Its methods and properties are
available again as before, but its event handers do not respond to any
events this time, although they responded the first time.
This a multithreaded environment, but I don't think that is causing any
problems in this case.
I hope this is enough code to illustrate the problem. Any ideas would be
most appreciated.