I’ve developed a C# program which I’m using as a child process of a parent process ( which is written in a different programming language than C#, namely: Smallworld Magik ). Standard I/O Channels to the C# program are used to communicate.
The meaning is to communicate with the C# program from the Smallworld Magik process. So, the C# program should receive commands from the Smallworld Magik process, and the Smallworld Magik process should receive the results/updates of the C# program.
The C# program initially receives the arguments by the main method of the program.
The C# program writes the results/updates to the Output Channel and the Smallworld Magik process receives and handles them.
No problems till here.
The problem is located in receiving input commands from the Input Channel ( System.Console.In ) by the C# program. I’m using the System.Console.ReadLine() method to get the input command. Calling this method blocks further Program execution.
Does someone have a “non-blocking” solution to this?
Since I’m a rooky C# developer, keep it low-level :).
You could use Threading, and since you say you’re a rooky i’m gonna direct you to the tutorial because threading is tricky and you should know what you’re doing: http://msdn.microsoft.com/en-us/library/aa645740(v=vs.71).aspx
Next thing you do is create a seperate thread for the ReadLine and invoke the result back to the main thread. Like this: