开发者

What arguments should be passed to Asychronous functions

开发者 https://www.devze.com 2023-04-11 17:32 出处:网络
I am new to unit testing. How can I pass arguments into the below function OnDefineInDictCompleted client.DefineInDictCompleted += new EventHandler&l开发者_开发百科t;DefineInDictCompletedEventArgs&

I am new to unit testing. How can I pass arguments into the below function

OnDefineInDictCompleted

client.DefineInDictCompleted += new EventHandler&l开发者_开发百科t;DefineInDictCompletedEventArgs>(OnDefineInDictCompleted);
OnDefineInDictCompleted(object sender, DefineInDictCompletedEventArgs e)


Rather than define OnDefineInDictCompleted as a method how about using anonymous delegates?

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

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

client.DefineInDictCompleted += handler;
0

精彩评论

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

关注公众号