Passing delegate with return type other than void in thread
I want to pass a delegate with the return 开发者_JAVA技巧type as ArrayList as parameter of thread and want to store the values in an ArrayList as well. Any help in this regard will be appreciated.
Instead of having a return value you could try passing in another parameter by reference:
private class ThreadArguments
{
public ArrayList List1 { get; set; }
public ArrayList List2 { get; set; }
public ThreadArguments(ArrayList list1, ref ArrayList list2)
{
this.List1 = list1;
this.List2 = list2;
}
}
Thread myThread = new Thread(new ParameterizedThreadStart(...));
myThread.Start(args);
So the return value is effectively replaced by list2.
精彩评论