Getting into a Session

We have two buttons on our form for either hosting or connecting to an existing session. Once we try to do either of these actions, we will need to disable these buttons so that we can't try to do more than one action at a time. The event handlers for these two buttons would be

private void button1_Click(object sender, System.EventArgs e)
{
    button1.Enabled = false;
    button2.Enabled = false;
    InitializeDirectPlay(true);
}

private void button2_Click(object sender, System.EventArgs e)
{
    button1.Enabled = false;
    button2.Enabled = false;
    InitializeDirectPlay(false);
}

As you see, they are both remarkably similar. The only difference between the two is the parameter they pass in to the InitializeDirectPlay method; one uses true ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.