none
About the Proceess.StandardInput buffer issue RRS feed

  • Question

  • hi everybody:
        I met the same problem with the link:http://social.msdn.microsoft.com/forums/en-US/clr/thread/62a06c51-c4bb-4a8e-8c04-e1e2e27167b2
        but I still can not solve it,can anybody help me?
        the follow is my test code:
    Imports System.IO
    
    Module Module1
    
        Sub Main()
    
            Dim aa(500) As String
    
            For i As Integer = 0 To 500
                aa(i) = "echo 12345678901234567890123456789012345678901234567890123456789012345678901234567890"
            Next
    
            EXECCMD(aa)
    
            Console.ReadKey()
    
        End Sub
    
        Private Sub EXECCMD(ByVal sCmd() As String)
            Dim MyProcess As New Process
    
            Dim b As Integer
    
    
            Try
                MyProcess.StartInfo.FileName = "cmd.exe"
    
                MyProcess.StartInfo.UseShellExecute = False
    
                MyProcess.StartInfo.RedirectStandardInput = True
    
                MyProcess.StartInfo.RedirectStandardOutput = True
    
                MyProcess.StartInfo.RedirectStandardError = True
    
                MyProcess.StartInfo.CreateNoWindow = True
    
                MyProcess.Start()
    
                For i As Integer = 0 To sCmd.GetUpperBound(0)
                    Console.WriteLine("sCmd(" & i & ")=" & sCmd(i))
                    b += sCmd(i).Length
                    MyProcess.StandardInput.WriteLine(sCmd(i))
                    Console.WriteLine("datalen=" & b)
                Next
    
                MyProcess.StandardInput.WriteLine("exit")
    
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
        End Sub
    End Module
    
       it will hang at the loop,I really want to know why,I guess it's relate to the StandardInput.buffersize,if so,how can I adjust it?
    Sunday, December 27, 2009 2:46 AM

Answers

All replies