Part 91 - Retrieving data from Thread function using callback method

In this video we will discuss, retrieving data from Thread function using callback method. This is continuation to Part 90. Please watch Part 90 before proceeding. We will be working with the same example we worked with in Part 90.

usingSystem;

usingSystem.Threading;

namespaceThreadStartDelegateExample

{

// Step 1: Create a callback delegate. The
actual callback method

// signature should match with the signature
of this delegate.

publicdelegatevoidSumOfNumbersCallback(intsumOfNumbers);

// Step 2: Create Number class to compute the
sum of numbers and

// to call the callback method

classNumber

{

// The traget number this class needs to
compute the sum of numbers

int_target;

// Delegate to call when the the Thread
function completes // computing the sum of numbers

SumOfNumbersCallback_callbackMethod;

// Constructor to initialize the target
number and the callback delegateinitialize