Wake up control

N

nondos

Hi

I have solution with two projects, one of them is a user control
I created public shared sub in the user control which mean to wake up the
control and start doing somthing, but when i try to call it from the main
project i get error message
"Cannot refer to an instance member of a class from within a shared method
or shared member initializer without an explicit instance of the class."
What can i do?

Thanks
 
R

rowe_newsgroups

Hi

I have solution with two projects, one of them is a user control
I created public shared sub in the user control which mean to wake up the
control and start doing somthing, but when i try to call it from the main
project i get error message
"Cannot refer to an instance member of a class from within a shared method
or shared member initializer without an explicit instance of the class."
What can i do?

Thanks

If you have to "wake up" each instance of the user control you need to
keep a reference to each instance in a shared variable (I would use a
dictionary or hashtable myself). You can add an instance to the list
of in the UserControl's constructor. To remove the instance reference,
I would have the UserControl implement IDisposible and remove itself
from the list in it's Dispose method (be sure to call dispose manually
- don't wait for the GC to do it for you). Then in your shared "wake
up" method you can loop through the list of instances and wake them
up.

Thanks,

Seth Rowe
 
N

nondos

Thanks

rowe_newsgroups said:
If you have to "wake up" each instance of the user control you need to
keep a reference to each instance in a shared variable (I would use a
dictionary or hashtable myself). You can add an instance to the list
of in the UserControl's constructor. To remove the instance reference,
I would have the UserControl implement IDisposible and remove itself
from the list in it's Dispose method (be sure to call dispose manually
- don't wait for the GC to do it for you). Then in your shared "wake
up" method you can loop through the list of instances and wake them
up.

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top