first_page

The Windows Forms Client Layer

Client Layer Type The Windows Forms designs here feature a class of static members called ClientLayer. This type now has a clearly defined first purpose: it handles calls from worker threads to the UI thread. Doing this, it defines all of the common UI behaviors of the Client—and the associated delegates needed for BeginInvoke() calls. This design avoids creating delegates for a bunch of event procedures of the Client and doing InvokeRequired checks in every single event procedure. Instead, event procedures call ClientLayer members—and these static members do all of the invoke stuff. This design is based on the assumption that the number of Client behaviors will always be less than the number of Client event procedures.

Examples of “Client behaviors” are disabling a control (such as a Button) during a long-running procedure or setting text on the status bar. The Visual Studio .NET Class View at left expands upon this sketch.

rasx()