Shared variables not working when create a new class instance

56 Views Asked by At

I have a class (ServerASync) with a shared Hashtable variable bSocket_Monitored. The variable values of bSocket_Monitored are shared between instances in different way in respect to how I declare the instances.

In the main form, if I declare the class instances as:

private withevents P1 as new ServerASync
private withevents P2 as new ServerASync
private withevents P3 as new ServerASync

etc.. all of them share the same bSocket_Monitored.

But if declare a new instance as:

private withevents P4 as ServerASync

and then

P4 = new ServerASync

the bSocket_Monitored is reset and lost all the previous values.

Can you help me? Thanks

0

There are 0 best solutions below