Tools used: Visual Studio 2019, Asp.net core 5.0, CefSharp.WinForms v79.0
I have created an asp.net core app and a CefSharp browser.
If i click on the app.core and then on the browser it works fine.
I would like to some kind "automate" the whole process.
How to start the Asp.net core app before the CefSharp fully loads/starts.
Can this be done from within the CefSharp browser,
so it opens the app.core in automatic and closes it too when CefSharp is closed?
i can already do this by cmd-line:
tasklist /fi "imagename eq APP.exe" |find ":" > nul
if errorlevel 1 taskkill /F /IM "APP.exe"
start C:\Server\APP.exe
start C:\CEFSHARP\GUI.exe
You can start and stop process "C:\Server\APP.exe"
from within GUI.EXE
- this is assuming that you have a source code for GUI.EXE
You need to do the following in GUI.EXE
source code (here I'm assuming that you are using Windows Forms application):
"C:\Server\APP.exe"
. You can use System.Diagnostics.Process.Start(@"C:\Server\APP.exe");
within event handler to start a process. Note that this method will return Process
object which can be used to close the application."C:\Server\APP.exe"
You can do this via CloseMainWindow method of the Process object.This worked for me:
Form1.cs
private void Form1_Load(object sender, EventArgs e)
{
Process[] processName = Process.GetProcessesByName("APP");
if (processName.Length == 0)
{
Process myprocess = new Process();
myprocess.StartInfo.FileName = "C:\\Server\\APP.exe";
myprocess.Start();
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
foreach (Process p in Process.GetProcessesByName("APP"))
{
p.Kill();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.