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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.