【问题标题】:making a synchronous calls for other applications对其他应用程序进行同步调用
【发布时间】:2010-03-11 14:34:16
【问题描述】:

我需要从我的代码中调用其他程序。

我需要等到它完成(同步调用)。

我该怎么做?

非常感谢。

【问题讨论】:

标签: c# .net ipc


【解决方案1】:

尝试使用WaitForExit 方法。

 Process p = new Process();
 // Redirect the error stream of the child process.
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardError = true;
 p.StartInfo.FileName = "OtherProgram.exe";
 p.StartInfo.Arguments = "My Arguments";
 p.Start();
 // Wait for the child process to exit.
 p.WaitForExit();

【讨论】:

【解决方案2】:

除非您显式进行异步调用,否则调用将是同步的(因此会阻塞当前线程)。执行这些操作的细节取决于您使用的所选应用程序到应用程序的通信机制。

这可能是:

  • TCP/IP
  • HTTP
  • WCF
  • 共享内存
  • 命名管道

还有更多。所有这些都允许您等待响应。

但具体情况非常不同(就像您使用每种方式时一样),因此如果没有更多关于您尝试实现的通信类型的详细信息,就无法更具体。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多