本文整理汇总了C#中DataReceivedEventHandler类的典型用法代码示例。如果您正苦于以下问题:C# DataReceivedEventHandler类的具体用法?C# DataReceivedEventHandler怎么用?C# DataReceivedEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataReceivedEventHandler类属于命名空间,在下文中一共展示了DataReceivedEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static ShellProcess Run(String cmd, String args,
DataReceivedEventHandler outputDataReceivedEventHandler,
DataReceivedEventHandler errorDataReceivedEventHandler)
{
return RunShellProcess(new ShellProcess(
cmd, args, outputDataReceivedEventHandler, errorDataReceivedEventHandler));
}
示例2: startJavaShell
public bool startJavaShell(DataReceivedEventHandler dataReceivedCallBack, string extraExecutionArguments)
{
try
{
classPath = getListOfCurrentJarStubsForClassPath(classPath);
var executionArguments = string.Format(ikvm.IKVMExecution_Script,
classPath, classToExecute, extraExecutionArguments);
if (extraExecutionArguments!="")
executionArguments += " " + extraExecutionArguments;
var executionWorkingDirectory = PublicDI.config.CurrentExecutableDirectory;
dataReceived = null;
inputStream = null;
IKVMProcess = null;
IKVMProcess = Processes.startProcessAndRedirectIO(ikvm.IKVMExecutable, executionArguments, ref inputStream, dataReceivedCallBack, dataReceivedCallBack);
if (inputStream != null)
return true;
"in startJavaShell , IKVMProcess.inputStream == null".error();
}
catch (Exception ex)
{
ex.log();
}
return false;
}
示例3: OnDataReceived
void OnDataReceived(DataReceivedEventHandler handler, DataReceivedEventArgs e)
{
if (handler != null)
{
handler(this, e);
}
}
示例4: CheckSshKey
public static Process CheckSshKey(string szSSHURL, DataReceivedEventHandler AppHandleOutput, DataReceivedEventHandler AppHandleError, EventHandler AppHandleAbort)
{
szSSHURL=szSSHURL.TrimEnd(':');
string szPort = null;
string szUrl = szSSHURL;
int nPos = szSSHURL.LastIndexOf(":");
if (nPos >= 0)
{
szPort = szSSHURL.Substring(nPos + 1, szSSHURL.Length - nPos - 1);
szUrl = szSSHURL.Substring(0, nPos );
}
string szExeArgument;
if(string.IsNullOrEmpty(szPort.Trim()))
{
szExeArgument = string.Format("-T \"{0}\"", szUrl); ;
}
else
{
szExeArgument = string.Format("-T -p {0} \"{1}\"", szPort, szUrl); ;
}
string.Format("-T -p 29418 [email protected] \"{0}\"", szSSHURL);
return CGitSourceConfig.m_objGitSrcModule.RunCommonCmdAsynch(@"ssh", szExeArgument, AppHandleOutput, AppHandleError, AppHandleAbort);
}
示例5: RunSimulation
public override void RunSimulation(DataReceivedEventHandler outputDataReceived, DataReceivedEventHandler errorDataReceived, EventHandler exited)
{
CreateCtlFile();
CreateShellScript();
ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = CygwinDirectoryPath + "\\" + CygwinExecutionFilePath;
pInfo.UseShellExecute = false;
pInfo.CreateNoWindow = true;
pInfo.RedirectStandardInput = true;
pInfo.RedirectStandardOutput = true;
pInfo.RedirectStandardError = true;
CygwinProcess = new Process();
CygwinProcess.StartInfo = pInfo;
CygwinProcess.OutputDataReceived += outputDataReceived;
CygwinProcess.ErrorDataReceived += errorDataReceived;
CygwinProcess.Exited += exited ?? new EventHandler( (object o, EventArgs e) => { } );
CygwinProcess.Start();
CygwinProcess.EnableRaisingEvents = true;
CygwinProcess.BeginOutputReadLine();
CygwinProcess.BeginErrorReadLine();
CygwinProcess.StandardInput.WriteLine( @"cd " + WorkingDirectoryPathInCygwin );
CygwinProcess.StandardInput.WriteLine( @"./simulation.sh" );
//CygwinProcess.StandardInput.WriteLine( @"" );
//CygwinProcess.StandardInput.WriteLine( @"" );
//CygwinProcess.StandardInput.WriteLine( @"" );
CygwinProcess.StandardInput.WriteLine( @"exit" );
}
示例6: StartLivestreamer
private Task StartLivestreamer(string inputUrl, DataReceivedEventHandler onData)
=> Task.Run(() =>
{
Process livestreamer = new Process
{
StartInfo =
{
FileName = Config.LivestreamerDir,
Arguments = $"--stream-url {inputUrl} best",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
},
EnableRaisingEvents = true
};
livestreamer.OutputDataReceived += onData;
if (!livestreamer.Start())
Logger.FormattedWrite(typeof (TrackData).Name, "Failed starting livestreamer.",
ConsoleColor.Red);
livestreamer.BeginOutputReadLine();
livestreamer.WaitForExit();
livestreamer.OutputDataReceived -= onData;
});
示例7: Run
public static void Run(string testArgument, DataReceivedEventHandler dataReceived = null)
{
string jarArgs = String.Format("{0} {1}", JavaArgs, testArgument);
var processInfo = new ProcessStartInfo(JavaExecutable, jarArgs)
{
CreateNoWindow = true,
UseShellExecute = false, // redirected streams
// redirect output stream
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
};
_process = new Process { StartInfo = processInfo, EnableRaisingEvents = true };
_process.OutputDataReceived += ProcessOnOutputDataReceived;
_process.ErrorDataReceived += ProcessOnErrorDataReceived;
if (dataReceived != null)
{
_process.OutputDataReceived += dataReceived;
_process.ErrorDataReceived += dataReceived;
}
_process.Start();
Trace.WriteLine("Java process started.");
_process.BeginOutputReadLine();
_process.BeginErrorReadLine();
Trace.WriteLine("Waiting for Java process to exit.");
_process.WaitForExit();
Trace.WriteLine("Java process exited.");
_process.Close();
}
示例8: SyncCmd
public SyncCmd(DataReceivedEventHandler hander = null)
{
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.ErrorDataReceived += hander ?? new DataReceivedEventHandler(p_ErrorDataReceived);
p.StartInfo.WorkingDirectory = System.Environment.CurrentDirectory;
//设定程序名
p.StartInfo.FileName = "cmd.exe";
//关闭Shell的使用
p.StartInfo.UseShellExecute = false;
//重定向标准输入
p.StartInfo.RedirectStandardInput = true;
//重定向标准输出
p.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
p.StartInfo.RedirectStandardError = true;
//设置不显示窗口
p.StartInfo.CreateNoWindow = true;
}
示例9: ExecuteAndWaitForExit
public static int ExecuteAndWaitForExit(string filename, string arguments, string workingDirectory, TextWriter outputData, TextWriter outputError, int? timeout)
{
var entrance = new object();
DataReceivedEventHandler d1 = null;
if (outputData != null)
{
d1 = new DataReceivedEventHandler(delegate(object x1, DataReceivedEventArgs e)
{
lock (entrance)
{
outputData.Write(e.Data);
}
});
}
DataReceivedEventHandler d2 = null;
if (outputError != null)
{
d2 = new DataReceivedEventHandler(delegate(object x1, DataReceivedEventArgs e)
{
lock (entrance)
{
outputError.Write(e.Data);
}
});
}
return ExecuteAndWaitForExit(filename, arguments, workingDirectory, d1, d2, null, null, timeout);
}
示例10: CGitAsynchFomr
public CGitAsynchFomr()
{
syncContext = SynchronizationContext.Current;
ProcessReceiveData = new DataReceivedEventHandler(GitProcessReceiveData);
ProcessAbort = new ExitProcessHandler(GitProcessExit);
ProcessErrorData = new DataReceivedEventHandler(GitProcessErrorData);
}
示例11: executeAppScanDEScan
public Process executeAppScanDEScan(string targetFolder,string tempAppScanWorkingDirectory, DataReceivedEventHandler onAppScanLogEvent)
{
var executable = "java.exe";
var executableParams = appScanDECommandLineParams1 + appScanDECommandLineParams2 +
appScanDECommandLineParams3 + appScanDECommandLineParams4 +
appScanDECommandLineParams5 + appScanDECommandLineParams6 + " \"" + targetFolder + "\" \"" + tempAppScanWorkingDirectory + "\"";
return Processes.startProcessAsConsoleApplication(executable, executableParams, onAppScanLogEvent);
}
示例12: executeJavaFile
// if we pass a callback for logging we need to start a IKVM shell
public Process executeJavaFile(string fileToExecute, DataReceivedEventHandler dataReceivedCallBack)
{
var IKVMShell = new JavaShell(ikvm);
IKVMShell.compileJavaFile(fileToExecute);
IKVMShell.executeClassFile(dataReceivedCallBack);
//IKVMShell.startJavaShell(dataReceivedCallBack, fileToExecute);
return IKVMShell.IKVMProcess;
}
示例13: CGitAsynchControl
public CGitAsynchControl()
{
//callback initialize
syncContext = SynchronizationContext.Current;
ProcessReceiveData = new DataReceivedEventHandler(GitProcessReceiveData);
ProcessAbort = new ExitProcessHandler(GitProcessExit);
ProcessErrorData = new DataReceivedEventHandler(GitProcessErrorData);
m_WaitForm = null;
}
示例14: UpLoadBranchAsynch
//asynch operation
public static Process UpLoadBranchAsynch(string szRemoteRepoName, string szBranch,DataReceivedEventHandler AppHandleOutput, DataReceivedEventHandler AppHandleError, EventHandler AppHandleAbort)
{
if (string.IsNullOrEmpty(szRemoteRepoName) || string.IsNullOrEmpty(szBranch))
{
return null;
}
string szExeCmd = string.Format("push {0} {1}", szRemoteRepoName, szBranch);
return CGitSourceConfig.m_objGitSrcModule.RunGitCmdAsynch(szExeCmd, AppHandleOutput, AppHandleError, AppHandleAbort);
}
示例15: ShellProcess
public ShellProcess(String cmd, String args, DataReceivedEventHandler outputDataReceivedEventHandler)
{
ProcStartInfo = new ProcessStartInfo(cmd, args);
ProcStartInfo.RedirectStandardError = true;
ProcStartInfo.RedirectStandardOutput = true;
ProcStartInfo.UseShellExecute = false;
ProcStartInfo.CreateNoWindow = true;
m_OutputDataReceivedEventHandler = outputDataReceivedEventHandler;
m_ErrorDataReceivedEventHandler = null;
}