asp net 3.5unleashed

Page 329

setOfItems.ProcessItems(fb); Console.WriteLine(); }

static void FeedbackToConsole( Object value, Int32 item, Int32 numItems) { Console.WriteLine("Processing item {0} of {1}: {2}.", item, numItems, value); }

static void FeedbackToMsgBox( Object value, Int32 item, Int32 numItems) { MessageBox.Show(String.Format("Processing item {0} of {1}: {2}.", item, numItems, value)); }

static void InstanceCallbacks() { // Create a set with five items in it. Set setOfItems = new Set(5);

// Process the items, and give feedback to a file. App appobj = new App(); setOfItems.ProcessItems(new Set.Feedback(appobj.FeedbackToF ile)); Console.WriteLine(); }

void FeedbackToFile( Object value, Int32 item, Int32 numItems) {

StreamWriter sw = new StreamWriter("Status", true); sw.WriteLine("Processing item {0} of {1}: {2}.", item, numItems, value); sw.Close(); } } Now I’ll describe what this code is doing. At the top, notice the Set class. Pretend that this class contains a set of items that will be processed individually. When you create a Set


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.