Saturday, May 2, 2015

Console.ReadLine() not working with .net Framework > 3.5

Here is a dummy sample code for the master app:
It uses the Qt framework, and is a Qt console application.
Type ping in the console, and the C# app should answer ping back.

#include <QCoreApplication>
#include <QProcess>
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // Path to the C# executable
    QString program = "D:/Documents/ConsoleApplication1/ConsoleApplication1/bin/Release/ConsoleApplication1.exe";

    // Start child Process
    QProcess * process = new QProcess();
       process->setProgram(program);
       // Execute lambda function whenever a message from the process is received
       QObject::connect(process, &QProcess::readyReadStandardOutput, [&](){ cout << process->readAll().toStdString(); } );
       process->start();

    string text;
    cin >> text;
    process->write( QByteArray::fromStdString(text) + "\r\n" );

    return a.exec();
}





@SimplelsBetter,

Per my understanding, Console.ReadLine() haven't change in .NET farmework >3.5. I am curious about how they communicate between them.

After consult with my colleague, about Qt framework is a third-party product.

Please also submit a question in QT forum.

http://ift.tt/1boGGWF

Thanks for your understanding.

Best regards,

Kristin


We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.


No comments:

Post a Comment