Передача массива через анонимные каналы - C#
Формулировка задачи:
Ребята, задача: передать массив из миллиона элементов от канала сервера каналу клиенту. Использовать анонимные каналы и метод синхронизации lock. Написал программу, но она передает массив размерностью не более 1300 элементов (примерно). Пожалуйста, подскажите, что делать.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.IO.Pipes;
namespace MultiThread
{
class Program
{
static object Locker = new object();
static public Stream outStream;
static public Stream inStream;
public static AnonymousPipeServerStream pipeServer;
public static AnonymousPipeClientStream pipeClient;
static public string pipeHandle = "";
static public int n = 0;
public static void channelOut()
{
lock (Locker)
{
pipeServer = new AnonymousPipeServerStream(PipeDirection.Out);
outStream = pipeServer;
pipeHandle = pipeServer.GetClientHandleAsString();
StreamWriter writer = new StreamWriter(outStream);
int[] array;
Console.WriteLine("Введите размерность массива ");
n = Convert.ToInt32(Console.ReadLine());
array = new int[n];
Random rnd = new Random();
for (int i = 0; i < n; i++)
{
array[i] = (1 + rnd.Next(10));
//Console.Write("{0}|", array[i]);
}
for (int i = 0; i < n; i++)
{
writer.WriteLine(array[i]);
}
writer.Close();
}
}
private static void channelIn()
{
Thread.Sleep(1000);
lock (Locker)
{
pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeHandle);
inStream = pipeClient;
StreamReader Reader = new StreamReader(pipeClient);
int[] mas3 = new int[n];
Console.WriteLine("");
for (int i = 0; i < n; i++)
{
mas3[i] = Convert.ToInt32(Reader.ReadLine());
Console.Write("{0}|", mas3[i]);
}
Reader.Close();
}
}
public static void Main()
{
Thread th1 = new Thread(() => channelOut());
Thread th2 = new Thread(() => channelIn());
th1.Start();
th2.Start();
th1.Join();
th2.Join();
Console.ReadLine();
}
}
}Решение задачи: «Передача массива через анонимные каналы»
textual
Листинг программы
pipeServer = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable, 1000000000);