如何将参数传递给 ElapsedEventHandler 调用的函数?
我的代码:
private static void InitTimer(int Index)
{
keepAlive[Index] = new Timer();
keepAlive[Index].Interval = 3000;
keepAlive[Index].Elapsed += new ElapsedEventHandler(keepAlive_Elapsed[, Index]);
keepAlive[Index].Start();
}
public static void keepAlive_Elapsed(object sender, EventArgs e[, int Index])
{
PacketWriter writer = new PacketWriter();
writer.AppendString("KEEPALIVE|.\\");
ServerSocket.Send(writer.getWorkspace(), Index);
ServerSocket.DisconnectSocket(Index);
}
我想要做的是括号([和])之间。但是,就那样做显然是行不通的……