2011-10-10 96 views
0

我是單元測試的新手。如何傳遞參數到下面的功能應該將什麼參數傳遞給異步函數

OnDefineInDictCompleted

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

回答

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;