本文整理汇总了C#中Program.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Program.Start方法的具体用法?C# Program.Start怎么用?C# Program.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program.Start方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
var p = new Program();
p.Start();
Console.ReadLine();
}
示例2: Start_ShouldFailWithPrettyErrorMessage
public void Start_ShouldFailWithPrettyErrorMessage()
{
program = new Program(console, translator, null, null);
program.Start(arguments);
translator.Received().Translate("StartErrorMessage");
console.Received().WriteLine("StartErrorMessage");
console.Received().WriteLine("Object reference not set to an instance of an object.");
}
示例3: Main
static void Main(string[] args)
{
Trace.Listeners.Add(new ConsoleTraceListener());
var executable = Environment.CommandLine.Replace("\"", string.Empty).Replace(".vshost", string.Empty);
Process remoteProcess = null;
string localUri, remoteUri;
if (args.Length == 0)
{
const string endpoint1 = "msmq://[email protected]";
const string endpoint2 = "msmq://[email protected]";
localUri = endpoint1;
remoteUri = endpoint2;
var startInfo = new ProcessStartInfo(executable, string.Format("\"{0}\" \"{1}\"", endpoint2, endpoint1));
startInfo.UseShellExecute = true;
startInfo.CreateNoWindow = false;
remoteProcess = Process.Start(startInfo);
}
else if (args.Length != 2)
{
Console.WriteLine("Usage: {0} [local endpoint] [remote endpoint]", executable);
return;
}
else
{
localUri = args[0];
remoteUri = args[1];
}
var instance = new Program(localUri, remoteUri);
try
{
instance.Start();
}
finally
{
if (remoteProcess != null && !remoteProcess.HasExited)
remoteProcess.Kill();
}
}
示例4: Main
static void Main(string[] args)
{
App app = new Program();
app.InitIO();
app.Start(args);
}
示例5: RunAndWait
public static int RunAndWait(string fileName, string arguments, out string result, [Optional, DefaultParameterValue(null)] IDictionary<string, string> environmentVariables)
{
ProcessStartInfo si = new ProcessStartInfo(fileName, arguments) {
CreateNoWindow = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
if (environmentVariables != null)
{
foreach (KeyValuePair<string, string> pair in environmentVariables)
{
si.EnvironmentVariables.Add(pair.Key, pair.Value);
}
}
using (Program program = new Program(si))
{
program.Start();
program.WaitForExit();
result = program.GetStandardOutputAsString();
return program.ExitCode;
}
}