Reputation: 21
I am building a program for the purposes of displaying Smartgraph3 readings. Whenever I start debugging, the command line opens but it then immediately disappears. I know ctrl + f5 works, but I was looking for a solution where I would not have to enter the same command to keep it from disappearing.
I have used System("pause"); but it keeps coming up with a blue line under System, and in the error list says 'System' is a 'namespace' but is used like a 'variable'. Does anybody know what is wrong?
Also, I have heard System("pause") should not be used, so does anybody have an alternative that's just as effective?
Here is a copy of my code. Thank you.
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Infowerk.SmartGraph3.SmartGraph3API;
//using CSTestClient.SmartGraph;
namespace CSTestClient
{
class Program
{
static void Main(string[] args)
{
TestAPI();
}
static void TestAPI()
{
System.ServiceModel.Channels.Binding service_binding = new BasicHttpBinding();
EndpointAddress endpoint_address = new EndpointAddress("http://localhost:8000/SmartGraph3API/APIV01");
SmartGraph3APIClient client = new SmartGraph3APIClient(service_binding, endpoint_address);
List<SG3APIDeviceIdentification> device_list = client.GetDeviceList();
foreach (SG3APIDeviceIdentification device_identification in device_list)
{
Console.WriteLine("device id: {0}", device_identification.DeviceId);
System("pause");
}
}
}
}
Upvotes: 0
Views: 6909
Reputation: 8316
Set a breakpoint on the closing brace of your Main()
. Or use an IDE which streams console output to a debug window which persists after the process exits (e.g., Eclipse, I assume basically anything other than VS). No reason to force everyone who actually wants to run your program the normal way to invoke it like:
:; ./myProgram.exe < /dev/null; exit $?
.\myProgram.exe < NUL
See https://stackoverflow.com/a/20487235.
Upvotes: 1