应该将哪些参数传递给异步函数

时间:2011-10-10 08:11:38

标签: windows-phone-7

我是单元测试的新手。如何将参数传递给下面的函数

OnDefineInDictCompleted

client.DefineInDictCompleted += new EventHandler<DefineInDictCompletedEventArgs>(OnDefineInDictCompleted);
OnDefineInDictCompleted(object sender, DefineInDictCompletedEventArgs e)

1 个答案:

答案 0 :(得分:1)

而不是将OnDefineInDictCompleted定义为使用匿名委托的方法?

var parameterA = 1;
var parameterB = "Foo";

EventHandler<DefineInDictCompletedEventArgs> handler = (s, e) =>
{
    //Can access local variables here;
    var x = parameterA.ToString() + parameterB;
};

client.DefineInDictCompleted += handler;