passing function to thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nicromonicon
    New Member
    • Aug 2007
    • 2

    #1

    passing function to thread

    hi...i was doing this simple calculator application,it takes an integer from user,and outputs the factorial and accumulated sum from zero..
    here is the code:

    private void btn_Click(objec t sender, EventArgs e)
    {
    int number = int.Parse(txt_n um.Text);
    txt_sum.Text = getsum(number). ToString();
    txt_fact.Text = getfact(number) .ToString();
    }

    private int getfact(int number)
    {
    if (number == 1 || number == 0)
    {
    return number;
    }
    else
    {
    return number * getfact(number-1);
    }
    }


    i want to pass function getfact to a thread,but when i declare a new thread,it says that return type must be void..any solution to work this with recursion or other functions that doesnt have void as a return type??

    thanks in advance :)
Working...