Connecting Tech Pros Worldwide Forums | Help | Site Map

Wake up control

nondos
Guest
 
Posts: n/a
#1: Aug 20 '07
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

rowe_newsgroups
Guest
 
Posts: n/a
#2: Aug 20 '07

re: Wake up control


On Aug 20, 10:52 am, "nondos" <non...@hotmail.comwrote:
Quote:
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

nondos
Guest
 
Posts: n/a
#3: Aug 21 '07

re: Wake up control


Thanks

"rowe_newsgroups" <rowe_email@yahoo.comwrote in message
news:1187631215.970867.253420@22g2000hsm.googlegro ups.com...
Quote:
On Aug 20, 10:52 am, "nondos" <non...@hotmail.comwrote:
Quote:
>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
>
Closed Thread