C
C# Learner
My bug's back. It's reappeared even though I haven't made any changes
since.
Just to check: is the use of locking in the following okay? Note that
'connections' and 'activeConnections' both reference instances of
'ArrayList'.
void connection_Drop(object sender, bool allSent)
{
lock (connections) {
connections.RemoveAt(connections.IndexOf(sender));
}
lock (activeConnections) {
int i = activeConnections.IndexOf(sender);
if (i != -1) {
activeConnections.RemoveAt(i);
ClientTransferEnd(this, i, allSent);
}
}
}
Here it is without K&R bracing style:
void connection_Drop(object sender, bool allSent)
{
lock (connections)
{
connections.RemoveAt(connections.IndexOf(sender));
}
lock (activeConnections)
{
int i = activeConnections.IndexOf(sender);
if (i != -1)
{
activeConnections.RemoveAt(i);
ClientTransferEnd(this, i, allSent);
}
}
}
since.
Just to check: is the use of locking in the following okay? Note that
'connections' and 'activeConnections' both reference instances of
'ArrayList'.
void connection_Drop(object sender, bool allSent)
{
lock (connections) {
connections.RemoveAt(connections.IndexOf(sender));
}
lock (activeConnections) {
int i = activeConnections.IndexOf(sender);
if (i != -1) {
activeConnections.RemoveAt(i);
ClientTransferEnd(this, i, allSent);
}
}
}
Here it is without K&R bracing style:
void connection_Drop(object sender, bool allSent)
{
lock (connections)
{
connections.RemoveAt(connections.IndexOf(sender));
}
lock (activeConnections)
{
int i = activeConnections.IndexOf(sender);
if (i != -1)
{
activeConnections.RemoveAt(i);
ClientTransferEnd(this, i, allSent);
}
}
}