Kill the process, solve runtime exception --- let 64-bit program calls the 32-bit program more smoothly

   On an essay written in 64-bit programs and 32 programs (https://www.cnblogs.com/Heavystudio/p/11059033.html), recently officially achieved a lot in the project, but there was a problem ,

Since 32-bit programs are also a large number of calls dll, resulting in each call and start dragging its feet are closed, resulting in abnormal operation occurs runtime error R6016 - not enough space for thread data, by trying to find,

This exception will change with the change of memory to run, the fundamental reason is because after multiple calls to 32-bit program, resulting in no memory space to create a new process.

  Statistics show that by the look, the problem often occurs in the C, C ++, Vb6 such as writing code in C # and like automatic memory management, it is generally not such a problem.

64-bit procedure is as follows:

process.Kill (); immediately kill all processes started by the 32-bit program, once, killing one, does not affect the next use
static void Main(string[] args)
        {// Create refpropPipe process
 Process process = new Process();
            // refpropPipe.exe on the same path with reference refprop64Hv, relative path
            process.StartInfo.FileName = @"C:\Users\Administrator\source\repos\refpropPipe\refpropPipe\bin\Debug\refpropPipe.exe";
             //process.StartInfo.FileName = "refpropPipe.exe";
            process.Start();
            double value = 0;
            // send call information to refpropPipe, that is, the query input variable values
            using (NamedPipeClientStream pipeClientStream = new NamedPipeClientStream("request"))
            {
                pipeClientStream.Connect();
                string input = Method + "," + FluidName + "," + InpCode + "," + Units + "," + Prop1 + "," + Prop2;
                using (StreamWriter writer = new StreamWriter(pipeClientStream))
                {
                    writer.WriteAsync(input);
                }
            }
            // receive information refpropPipe return, that results
            using (NamedPipeClientStream pipeClientStream = new NamedPipeClientStream("respose"))
            {
                pipeClientStream.Connect();
                using (StreamReader reader = new StreamReader(pipeClientStream))
                {
                    string val = reader.ReadToEnd();
                    value = Convert.ToDouble(val);
                }
            }
            //process.WaitForExit();
            //process.Close();
           // not wait, directly kill the process, save dragging its feet, Yoshiya Yoshiya
          process.Kill();
 
}

  

Guess you like

Origin www.cnblogs.com/Heavystudio/p/11101932.html