Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - strange behaviour on another process via Process.Start(startInfo) -- continue -


the original location (strange behaviour on process via process.start(startinfo)) doesn't allow me post test code properly. have start new question here.

our c#(v3.5) needs call c++ executable process raw data file , generate result files us.

it worked before following code (without readtoend() or readline() call):

startinfo.useshellexecute = false; startinfo.redirectstandarderror = true; startinfo.redirectstandardoutput = true; 

now input raw data file changed (bigger before). our call executable hang forever. based on advice, added readtoend() or readline() hang on calls. have either use startinfo.useshellexecute = true; or set

startinfo.useshellexecute = false;  // , startinfo.redirectstandarderror = false; startinfo.redirectstandardoutput = false; 

don't know why?

following cases tested:

  1. working case:

    processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = false; startinfo.redirectstandarderror = false; startinfo.redirectstandardoutput = false; startinfo.windowstyle = processwindowstyle.hidden; startinfo.filename = path; startinfo.arguments = rawdatafilename; //startinfo.workingdirectory = util.getparentdirectory(path, 1); try {     process correctionprocess = process.start(startinfo);     correctionprocess.waitforexit(); } 
  2. working case:

    processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = true; startinfo.redirectstandarderror = false;//can commented out startinfo.redirectstandardoutput = false;//can commented out startinfo.windowstyle = processwindowstyle.hidden; startinfo.filename = path; startinfo.arguments = rawdatafilename; startinfo.workingdirectory = util.getparentdirectory(path, 1); try {     process correctionprocess = process.start(startinfo);     correctionprocess.waitforexit(); } 
  3. not working case (using readline()):

    processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = false; startinfo.redirectstandarderror = true; startinfo.redirectstandardoutput = true; startinfo.windowstyle = processwindowstyle.hidden; startinfo.filename = path; startinfo.arguments = rawdatafilename; //startinfo.workingdirectory = util.getparentdirectory(path, 1); try {     process correctionprocess = process.start(startinfo);     while (!correctionprocess.hasexited)     {         log.logitem(logtype.performance, "read errormsg @@@@", "dptm::correctdata()", "");         string errormsg = correctionprocess.standarderror.readline(); // <-- hangs here         log.logitem(logtype.performance, "read errormsg", "dptm::correctdata()", "errormsg=" + errormsg);         string outputmsg = correctionprocess.standardoutput.readline();         log.logitem(logtype.performance, "read outputmsg", "dptm::correctdata()", "outputmsg=" + outputmsg);         thread.sleep(100);     } } 
  4. not working case (using readtoend()):

    processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = false; startinfo.redirectstandarderror = true; startinfo.redirectstandardoutput = true; startinfo.windowstyle = processwindowstyle.hidden; startinfo.filename = path; startinfo.arguments = rawdatafilename; //startinfo.workingdirectory = util.getparentdirectory(path, 1); try {     process correctionprocess = process.start(startinfo);     while (!correctionprocess.hasexited)     {         log.logitem(logtype.performance, "read errormsg @@@@", "dptm::correctdata()", "");         string errormsg = correctionprocess.standarderror.readtoend(); // <-- hangs here!         log.logitem(logtype.performance, "read errormsg", "dptm::correctdata()", "errormsg=" + errormsg);         string outputmsg = correctionprocess.standardoutput.readtoend();         log.logitem(logtype.performance, "read outputmsg", "dptm::correctdata()", "outputmsg=" + outputmsg);         thread.sleep(100);     } } 
  5. not working case:

    processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = false; startinfo.redirectstandarderror = true; startinfo.redirectstandardoutput = true; startinfo.windowstyle = processwindowstyle.hidden; startinfo.filename = path; startinfo.arguments = rawdatafilename; //startinfo.workingdirectory = util.getparentdirectory(path, 1); try {     process correctionprocess = process.start(startinfo);     log.logitem(logtype.performance, "read errormsg @@@@", "dptm::correctdata()", "");     string errormsg = correctionprocess.standarderror.readtoend(); // <-- hangs here!     log.logitem(logtype.performance, "read errormsg", "dptm::correctdata()", "errormsg=" + errormsg);     string outputmsg = correctionprocess.standardoutput.readtoend();     log.logitem(logtype.performance, "read outputmsg", "dptm::correctdata()", "outputmsg=" + outputmsg);     correctionprocess.waitforexit(); } 

you deadlocked on error/output buffer. second process waiting buffer free while waiting process finish. need asynchronously read output/error streams prevent that.

looking @ msdn sample: wow sample confusing... would've been easier follow if limited std out or std error.

you need first set data handler

correctionprocess.outputdatareceived += new datareceivedeventhandler(outputdatahandler); 

and call

p.beginoutputreadline(); 

just comment [confusingly] advises no try read output there. use handler instead.

    private void outputdatahandler(object sendingprocess, datareceivedeventargs data)     {         if (data.data != null)         {             // append data.data internal buffer (stringbuilder?)         }     } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -