Application tear down
instead of calling Environment.Exit(0); do a better tear down of the application
This commit is contained in:
parent
69083db0c4
commit
e0ab79715d
5 changed files with 29 additions and 3 deletions
|
@ -50,6 +50,10 @@ namespace Ryujinx
|
||||||
|
|
||||||
using (GLScreen Screen = new GLScreen(Ns, Renderer))
|
using (GLScreen Screen = new GLScreen(Ns, Renderer))
|
||||||
{
|
{
|
||||||
|
Ns.Finish += (Sender, Args) => {
|
||||||
|
Screen.Exit();
|
||||||
|
};
|
||||||
|
|
||||||
Screen.Run(60.0);
|
Screen.Run(60.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Ryujinx.OsHle.Handles;
|
||||||
using Ryujinx.OsHle.Utilities;
|
using Ryujinx.OsHle.Utilities;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.OsHle
|
namespace Ryujinx.OsHle
|
||||||
{
|
{
|
||||||
|
@ -135,6 +136,18 @@ namespace Ryujinx.OsHle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool ExitProcess(int ProcessId) {
|
||||||
|
Process process;
|
||||||
|
var Success = Processes.TryRemove(ProcessId, out process);
|
||||||
|
if (Success) {
|
||||||
|
process.StopAllThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Processes.Count == 0) {
|
||||||
|
Ns.OnFinish(EventArgs.Empty);
|
||||||
|
}
|
||||||
|
return Success;
|
||||||
|
}
|
||||||
internal bool TryGetProcess(int ProcessId, out Process Process)
|
internal bool TryGetProcess(int ProcessId, out Process Process)
|
||||||
{
|
{
|
||||||
if (!Processes.TryGetValue(ProcessId, out Process))
|
if (!Processes.TryGetValue(ProcessId, out Process))
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace Ryujinx.OsHle
|
||||||
{
|
{
|
||||||
if (MainThread != null)
|
if (MainThread != null)
|
||||||
{
|
{
|
||||||
while (MainThread.IsAlive)
|
if (MainThread.IsAlive)
|
||||||
{
|
{
|
||||||
MainThread.StopExecution();
|
MainThread.StopExecution();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ namespace Ryujinx.OsHle
|
||||||
|
|
||||||
foreach (AThread Thread in TlsSlots.Values)
|
foreach (AThread Thread in TlsSlots.Values)
|
||||||
{
|
{
|
||||||
while (Thread.IsAlive)
|
if (Thread.IsAlive)
|
||||||
{
|
{
|
||||||
Thread.StopExecution();
|
Thread.StopExecution();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.OsHle.Svc
|
||||||
{
|
{
|
||||||
private static void SvcExitProcess(Switch Ns, ARegisters Registers, AMemory Memory)
|
private static void SvcExitProcess(Switch Ns, ARegisters Registers, AMemory Memory)
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
Ns.Os.ExitProcess(Registers.ProcessId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SvcCloseHandle(Switch Ns, ARegisters Registers, AMemory Memory)
|
private static void SvcCloseHandle(Switch Ns, ARegisters Registers, AMemory Memory)
|
||||||
|
|
|
@ -24,6 +24,15 @@ namespace Ryujinx
|
||||||
VFs = new VirtualFs();
|
VFs = new VirtualFs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event EventHandler Finish;
|
||||||
|
internal virtual void OnFinish(EventArgs e)
|
||||||
|
{
|
||||||
|
EventHandler Handler = Finish;
|
||||||
|
if (Handler != null)
|
||||||
|
{
|
||||||
|
Handler(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue