本文介绍了控制台应用程序应等待,直到执行EXE的批处理文件为止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

需要你的帮助.我有一种情况,我需要从客户端控制台应用程序调用DMZ中的数据库服务器上托管的Web服务.Web服务应在数据库服务器本地启动一个批处理文件,该批处理文件将调用某些程序包,并且在处理该程序包时完成的批处理文件应将其通知给Console Client应用程序.为了测试目的,我编写了以下代码

字符串目标= @"c:\ Test Batch.bat";
流程proc = new Process();
proc.StartInfo.FileName =目标;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Exited + =新的EventHandler(proc_Exited);
proc.EnableRaisingEvents = true;
proc.Start();
proc.WaitForExit();

我还在本地创建了一个Web服务,并且能够通过Web服务调用来启动批处理文件.由于我需要向客户端报告该批处理文件已完成,因此我使用了Asyn方法,并注册了Web服务的onCompleted事件.但是,这是我的问题,未触发OnCompleted事件:(
我应该怎么做才能使其正常工作?

另外,如果我的批处理文件运行其他一些大约需要2个小时才能完成的EXE,则进程类将等待2个小时,直到EXE完成为止,或者在批处理文件启动EXE时退出,并且不要等待它完成?

另一个问题是,当数据库服务器位于DMZ上时,应使用哪种身份验证模式来保护Web服务?

如果我所有的问题都得到回答,我非常感谢.问候!



当您回答所有问题时,信心并没有到来,而当您准备面对所有问题时,信心就来了."

Dear Friends,

Need your help. I have a scenario where I need to call a webservice hosted on a database server in DMZ, from a client console application.The webservice should start a batch file, locally on database server, which calls some package and when the processing of that package is finished batch file should inform Console Client application about it. For my testing purpose I have written the below code

string target = @"c:\Test Batch.bat";
Process proc = new Process();
proc.StartInfo.FileName = target;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Exited += new EventHandler(proc_Exited);
proc.EnableRaisingEvents = true;
proc.Start();
proc.WaitForExit();

I also created a webservice locally and i am able to start the batch file via webservice call. Since I need to report back to client that batch file is finished, I used Asyn method, and registered for the onCompleted event of the webservice. But here is my problem, the OnCompleted event is not fired :(
What should i do to get it working ?

Also if my batch file is runnig some other EXE which takes about 2 hours to finish, the process class wait for 2 hours till the time EXE is finished or it exits when the batch file has started the EXE, and dont wait for it to finish ?

One other question, which authentication mode should be used to secure web service as the database server is on DMZ ?

Many thanks if all my questions are answered. Regards!



"Confidence does not come when you all the answers, It comes when you are ready to face all the questions"

推荐答案


这篇关于控制台应用程序应等待,直到执行EXE的批处理文件为止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 15:26