Home > Articles > Programming > C#

  • Print
  • + Share This
Like this article? We recommend

Putting It All Together

Let's now take a look at the last file of interest: Program.cs. Listing 8 illustrates the main program.

Listing 8 The Main Program

static void Main(string[] args)
// Instantiate an LSP
Lsp lsp = new Lsp("LSP123", 1, 5, "R2R3R4R5", 100, 150);
// Make sink object.
Console.WriteLine("Creating LSP event sink\n");
LspEventSink sink = new LspEventSink("Event sink");
// Attach the sink to the LSP.
Console.WriteLine("Attaching a sink to the LSP");
// Forward some blocks of data (to generate some events.)
Console.WriteLine("\n***** Forwarding data *****");
for (int i = 0; i < 3; i++)
Console.WriteLine("\n***** Forwarding more data *****");
for (int i = 0; i < 2; i++)
// Detach the sink from the LSP.
Console.WriteLine("Detaching a sink from the LSP");
Console.ReadLine(); }

Listing 8 illustrates the overall workflow from lsp and sink instantiation to lsp attachment to the sink followed by forwarding data and then finally lsp detachment.

  • + Share This
  • 🔖 Save To Your Account