开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜