I know this will probably will get marked as duplicate, but I have seen other questions and they don't clarify me. This is on one thread:
int indexOfList = 0;
long byteSent = 0;
byte[] chunkToSend;
while(bytesThatAreCompressed != byteSent || !finished)
{
if (indexOfList < listOfChunksToSend.Count)
{
int testinteger = listOfChunksToSend[indexOfList ].Length;
chunkToSend= new byte[testinteger];
chunkToSend= listOfChunksToSend[indexOfList ];
int tamanhoBufferComprimido = (int)chunkToSend.Length;
byte[] tamanhoChunkB = BitConverter.GetBytes(tamanhoBufferComprimido);
streamligacao.Write(tamanhoChunkB, 0, tamanhoChunkB.Length);
streamligacao.Write(chunkToSend, 0, tamanhoBufferComprimido);
byteSent += chunkToSend.Length;
indexOfList ++;
}
}
And this is on another thread:
listOfChunksToSend.Add(stream.ToArray());
It is throwing the exeption:
The object reference not set to an instance of an object .
listOfChunksToSend is a list of byte[]
When it throws this exception I check the variables and there is nothing wrong!
What am I doing wrong?