Click here to Skip to main content
15,900,461 members
Home / Discussions / C#
   

C#

 
GeneralRe: Loading an assembly fails in .NET 2.0 Pin
leppie20-Feb-06 22:22
leppie20-Feb-06 22:22 
Questionicon for menu item Pin
Praveen_S20-Feb-06 19:37
Praveen_S20-Feb-06 19:37 
QuestionUsing COM from Web Service Pin
Crazy Joe Devola20-Feb-06 19:05
Crazy Joe Devola20-Feb-06 19:05 
AnswerRe: Using COM from Web Service Pin
Crazy Joe Devola21-Feb-06 18:50
Crazy Joe Devola21-Feb-06 18:50 
QuestionGenerate multiple Bitmaps in memory Pin
NewbieDude20-Feb-06 18:52
NewbieDude20-Feb-06 18:52 
AnswerRe: Generate multiple Bitmaps in memory Pin
Ingo20-Feb-06 22:48
Ingo20-Feb-06 22:48 
GeneralRe: Generate multiple Bitmaps in memory Pin
NewbieDude21-Feb-06 3:26
NewbieDude21-Feb-06 3:26 
QuestionRedirecting Standard Input, Output and Error Pin
Dribble20-Feb-06 18:44
Dribble20-Feb-06 18:44 
Hi,
I am a newbie to C# and Im trying to redirect standard input, output and error of a console program written in C (MS VC 6.0) to a textbox on a form. The code for the redirecting looks like this:

private System.IO.StreamWriter c_StreamInput = null;
private System.IO.StreamReader c_StreamOutput = null;
private Thread c_ThreadRead = null;
private Process c_Process = null;

private void ReadStdOutputThreadProc()
{
try
{
string str = c_StreamOutput.ReadLine();
while(str != null)
{
txtboxCNF.AppendText(str+"\r\n");
Thread.Sleep(100);
str = c_StreamOutput.ReadLine();
}
}
catch(Exception) {}
}

private void btnStart_Click(object sender, System.EventArgs e)
{
if(c_Process == null)
{
c_Process = new Process();
ProcessStartInfo psi = new ProcessStartInfo("console.exe");
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
c_Process.StartInfo = psi;
c_Process.Start();

c_StreamInput = c_Process.StandardInput;
c_StreamOutput = c_Process.StandardOutput;

c_StreamInput.AutoFlush = true;

c_ThreadRead = new Thread(new ThreadStart(ReadStdOutputThreadProc));
c_ThreadRead.Start();
}
}

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (c_ThreadRead != null)
{
c_ThreadRead.Abort();
c_ThreadRead.Join();
}
if(c_Process != null && !c_Process.HasExited)
c_Process.Kill();
}

The console application that I am trying to run (console.exe) is a simple C program that prints a line text and then calls the getchar() function. The code is basically this:

#include "stdafx.h"
#include <conio.h>

int main(int argc, char* argv[])
{
printf ("Hello World !!\n");
int ch = getchar();
printf("Character = %s\n", ch);
return 0;
}

I have tried to run the C program without the getchar() function and it works. The problem arises when I use the getchar() function. I have tried getch() and gets() version without any success. I am not sure if I have to do anything special for showing output when using such functions.

Any help/pointers in this direction will be greately appreciated.

Thanks in advance.


Dribble
AnswerRe: Redirecting Standard Input, Output and Error Pin
leppie20-Feb-06 21:16
leppie20-Feb-06 21:16 
GeneralRe: Redirecting Standard Input, Output and Error Pin
Dribble21-Feb-06 9:51
Dribble21-Feb-06 9:51 
QuestionExcel in C# Pin
Acheive_it20-Feb-06 17:30
Acheive_it20-Feb-06 17:30 
AnswerRe: Excel in C# Pin
ChevyVanDude21-Feb-06 5:00
ChevyVanDude21-Feb-06 5:00 
QuestionHow use Paging DataGird in WinForms Pin
AnhTin20-Feb-06 17:02
AnhTin20-Feb-06 17:02 
QuestionDirectX Compiler Error Pin
Leo Smith20-Feb-06 16:18
Leo Smith20-Feb-06 16:18 
AnswerRe: DirectX Compiler Error Pin
Judah Gabriel Himango20-Feb-06 16:29
sponsorJudah Gabriel Himango20-Feb-06 16:29 
Questionrow and column count of excel file Pin
edel_ong20-Feb-06 14:24
edel_ong20-Feb-06 14:24 
AnswerRe: row and column count of excel file Pin
Judah Gabriel Himango20-Feb-06 16:31
sponsorJudah Gabriel Himango20-Feb-06 16:31 
QuestionHow to turn off executing Load event at design time feature? Pin
t800t820-Feb-06 13:57
t800t820-Feb-06 13:57 
AnswerRe: How to turn off executing Load event at design time feature? Pin
[Marc]20-Feb-06 14:20
[Marc]20-Feb-06 14:20 
GeneralRe: How to turn off executing Load event at design time feature? Pin
t800t820-Feb-06 14:30
t800t820-Feb-06 14:30 
AnswerRe: How to turn off executing Load event at design time feature? Pin
Dave Kreskowiak20-Feb-06 17:35
mveDave Kreskowiak20-Feb-06 17:35 
GeneralRe: How to turn off executing Load event at design time feature? Pin
t800t820-Feb-06 17:57
t800t820-Feb-06 17:57 
GeneralRe: How to turn off executing Load event at design time feature? Pin
J4amieC20-Feb-06 21:47
J4amieC20-Feb-06 21:47 
GeneralRe: How to turn off executing Load event at design time feature? Pin
Dave Kreskowiak21-Feb-06 13:23
mveDave Kreskowiak21-Feb-06 13:23 
GeneralRe: How to turn off executing Load event at design time feature? Pin
t800t821-Feb-06 13:28
t800t821-Feb-06 13:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.