我有这段代码
class Program
{
private static void test(int i)
{
Console.WriteLine(i);
}
static void Main(string[] args)
{
BackgroundWorker worker = new BackgroundWorker();
int i = 5;
worker.DoWork += (obj, ev) => test(i);
worker.RunWorkerAsync();
}
}
当我运行它时,没有打印任何内容。我做错了什么?