I have to process a large byte array that is passed to my function. I need to copy the content from this incoming byte array in smaller "chunks" to an outbound byte array.

For every "chunk" of data I need to call a web service.

Upon return, I need to resume looping through the incoming byte array, continuing to pass a whole or partial chunk of data until the complete byte array is processed (i.e. sent to the web service in chunks).

I am very new to C# and I am struggling with a loop that works. I know how to call the web service to handle a "chunk" but I can't get the looping correct. Here is a sketch of the pathetic mess I currently have:

Code:
int chunkSize = 10000;
byte[] outboundBuffer = new byte[chunkSize];     
while (BytesRead > 0)
{
	long i = 0;
	foreach (byte x in incomingArray)
	{
	    BytesRead += 1;
	    outboundBuffer[i] = incomingArray[i]
	    i++;
	}
	uploadObject.Size = BytesRead;
	uploadObject.MTOMPayload = outboundBuffer;
	
	// call web service here and pass the uploadObject 
	
	// get next "chunk" until incomingArray is fully processed 
}
Could one of you experts take this idea and show me the proper way to loop? Thanks very much in advance.