Click here to Skip to main content
15,909,530 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cut, Copy Paste TreeNodes Pin
Rafone26-May-09 2:47
Rafone26-May-09 2:47 
Questionanybody knows Tools for veiw problems with final code Pin
DVD_RR25-May-09 13:29
DVD_RR25-May-09 13:29 
QuestionSubscribe to event on all instances in array Pin
DaveyM6925-May-09 12:58
professionalDaveyM6925-May-09 12:58 
I have a class Input that has a static property Input[] Devices.

Instead of the user having to iterate over the array and subscribe to an event in each instance, I want to provide a mechanism where they can do it in one shot.

This works, but I wondered if there was a better way?
public class Input
{
    public event EventHandler<ConnectedEventArgs> Connected;

    public static Input[] Devices
    {
        get
        {
            // ...
        }
    }

    public static void SubscribeToAllConnected(EventHandler<ConnectedEventArgs> multicastDelegate)
    {
        foreach (Input device in Devices)
            device.Connected += multicastDelegate;
    }

    public static void UnsubscribeToAllConnected(EventHandler<ConnectedEventArgs> multicastDelegate)
    {
        foreach (Input device in Devices)
            device.Connected -= multicastDelegate;
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
Why are you using VB6? Do you hate yourself? (Christian Graus)

AnswerRe: Subscribe to event on all instances in array Pin
N a v a n e e t h25-May-09 17:29
N a v a n e e t h25-May-09 17:29 
GeneralRe: Subscribe to event on all instances in array Pin
DaveyM6925-May-09 23:03
professionalDaveyM6925-May-09 23:03 
QuestionTo stop keys Pin
ammoti25-May-09 11:51
ammoti25-May-09 11:51 
AnswerRe: To stop keys Pin
_Maxxx_25-May-09 12:12
professional_Maxxx_25-May-09 12:12 
AnswerRe: To stop keys Pin
EliottA25-May-09 12:14
EliottA25-May-09 12:14 
GeneralRe: To stop keys Pin
ammoti25-May-09 12:23
ammoti25-May-09 12:23 
GeneralRe: To stop keys Pin
EliottA25-May-09 12:38
EliottA25-May-09 12:38 
GeneralRe: To stop keys Pin
ammoti25-May-09 12:51
ammoti25-May-09 12:51 
GeneralRe: To stop keys Pin
EliottA25-May-09 12:51
EliottA25-May-09 12:51 
GeneralRe: To stop keys Pin
Dave Kreskowiak25-May-09 14:42
mveDave Kreskowiak25-May-09 14:42 
QuestionLooking for help getting started... Pin
Are Jay25-May-09 11:50
Are Jay25-May-09 11:50 
AnswerRe: Looking for help getting started... Pin
_Maxxx_25-May-09 12:14
professional_Maxxx_25-May-09 12:14 
GeneralRe: Looking for help getting started... Pin
Are Jay25-May-09 14:34
Are Jay25-May-09 14:34 
GeneralRe: Looking for help getting started... Pin
Dave Kreskowiak25-May-09 14:40
mveDave Kreskowiak25-May-09 14:40 
AnswerRe: Looking for help getting started... Pin
Dave Kreskowiak25-May-09 14:38
mveDave Kreskowiak25-May-09 14:38 
GeneralRe: Looking for help getting started... Pin
Are Jay25-May-09 15:51
Are Jay25-May-09 15:51 
GeneralRe: Looking for help getting started... Pin
Dave Kreskowiak25-May-09 17:51
mveDave Kreskowiak25-May-09 17:51 
GeneralRe: Looking for help getting started... Pin
Are Jay26-May-09 15:26
Are Jay26-May-09 15:26 
QuestionCurser and panel size change Pin
ytubis25-May-09 10:50
ytubis25-May-09 10:50 
AnswerRe: Curser and panel size change Pin
Luc Pattyn25-May-09 12:25
sitebuilderLuc Pattyn25-May-09 12:25 
QuestionSetting the UserAgent for WebRequest Pin
Brad Wick25-May-09 10:24
Brad Wick25-May-09 10:24 
QuestionFileIOPermission Problem Pin
Okultist25-May-09 10:07
Okultist25-May-09 10:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.