"Mes"vin
"Mes"vin
CC#
Created by "Mes"vin on 11/16/2024 in #help
Node process not being killed properly when WPF closes
c#
private Process _Client;
private Process _Server;
private List<Process> _ChildProcesses = new List<Process>();

public MainWindow()
{
InitializeComponent();

// Path to MonacoLuau folder
string monacoLuauPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MonacoLuau");
string nodeModulesPath = System.IO.Path.Combine(monacoLuauPath, "node_modules");

// Check if node_modules exists
if (Directory.Exists(nodeModulesPath))
{
string clientPath = System.IO.Path.Combine(monacoLuauPath, "Client");
string serverPath = System.IO.Path.Combine(monacoLuauPath, "Server");

_Client = StartProcess(clientPath, "run dev");
_Server = StartProcess(serverPath, "run dev");

// Track child processes of server and client
_ChildProcesses.AddRange(GetChildProcesses(_Client));
_ChildProcesses.AddRange(GetChildProcesses(_Server));
}
else
{
// Handle npm install logic
RunNpmInstall(monacoLuauPath);
}
}
c#
private Process _Client;
private Process _Server;
private List<Process> _ChildProcesses = new List<Process>();

public MainWindow()
{
InitializeComponent();

// Path to MonacoLuau folder
string monacoLuauPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MonacoLuau");
string nodeModulesPath = System.IO.Path.Combine(monacoLuauPath, "node_modules");

// Check if node_modules exists
if (Directory.Exists(nodeModulesPath))
{
string clientPath = System.IO.Path.Combine(monacoLuauPath, "Client");
string serverPath = System.IO.Path.Combine(monacoLuauPath, "Server");

_Client = StartProcess(clientPath, "run dev");
_Server = StartProcess(serverPath, "run dev");

// Track child processes of server and client
_ChildProcesses.AddRange(GetChildProcesses(_Client));
_ChildProcesses.AddRange(GetChildProcesses(_Server));
}
else
{
// Handle npm install logic
RunNpmInstall(monacoLuauPath);
}
}
3 replies
CC#
Created by "Mes"vin on 11/16/2024 in #help
Node process not being killed properly when WPF closes
C#
public void MainWindow_Closed(object sender, EventArgs e)
{
try
{
Console.WriteLine("Closing application...");

// Kill all child processes
foreach (var childProcess in _ChildProcesses)
{
Console.WriteLine($"Killing child process with PID: {childProcess.Id}");
if (!childProcess.HasExited)
{
childProcess.Kill();
childProcess.WaitForExit(); // Ensure it exits
}
}

// Kill the main client process
if (_Client != null && !_Client.HasExited)
{
Console.WriteLine($"Killing client process with PID: {_Client.Id}");
_Client.Kill();
_Client.WaitForExit();
}

// Kill the main server process
if (_Server != null && !_Server.HasExited)
{
Console.WriteLine($"Killing server process with PID: {_Server.Id}");
_Server.Kill();
_Server.WaitForExit(); // Ensure the server process exits
}

// Graceful shutdown
Application.Current.Shutdown();
}
catch (Exception ex)
{
MessageBox.Show($"Error while closing: {ex.Message}");
}
}
C#
public void MainWindow_Closed(object sender, EventArgs e)
{
try
{
Console.WriteLine("Closing application...");

// Kill all child processes
foreach (var childProcess in _ChildProcesses)
{
Console.WriteLine($"Killing child process with PID: {childProcess.Id}");
if (!childProcess.HasExited)
{
childProcess.Kill();
childProcess.WaitForExit(); // Ensure it exits
}
}

// Kill the main client process
if (_Client != null && !_Client.HasExited)
{
Console.WriteLine($"Killing client process with PID: {_Client.Id}");
_Client.Kill();
_Client.WaitForExit();
}

// Kill the main server process
if (_Server != null && !_Server.HasExited)
{
Console.WriteLine($"Killing server process with PID: {_Server.Id}");
_Server.Kill();
_Server.WaitForExit(); // Ensure the server process exits
}

// Graceful shutdown
Application.Current.Shutdown();
}
catch (Exception ex)
{
MessageBox.Show($"Error while closing: {ex.Message}");
}
}
3 replies
CC#
Created by "Mes"vin on 10/30/2024 in #help
How can I get all active windows that are fullscreen/maximized using the Win32, user32 api
Can I change the workarea somehow? So that all windows respect my custom taskbar
9 replies
CC#
Created by "Mes"vin on 10/30/2024 in #help
How can I get all active windows that are fullscreen/maximized using the Win32, user32 api
For example making sure chrome doesn't span the entire screen
9 replies
CC#
Created by "Mes"vin on 10/30/2024 in #help
How can I get all active windows that are fullscreen/maximized using the Win32, user32 api
Imitating the window taskbar, and making windows respect the space it takes up
9 replies