Restarting an application in the same process doesn't work on Windows
See original GitHub issueTake a look at my code here:
It’s not too complex it mostly does:
Application.Init();
var top = Application.Top;
top.RemoveAll();
// Creates the top-level window to show
var win = new Window(applicationData.Title ?? "Out-ConsoleGridView")
{
X = 0,
Y = 1, // Leave one row for the toplevel menu
// By using Dim.Fill(), it will automatically resize without manual intervention
Width = Dim.Fill(),
Height = Dim.Fill()
};
top.Add(win);
// Creates a menubar, the item "New" has a help menu.
var menu = new MenuBar(new MenuBarItem []
{
new MenuBarItem("_Actions (F9)",
applicationData.PassThru
? new MenuItem []
{
new MenuItem("_Accept", "", () => { if (Quit("Accept", ACCEPT_TEXT)) top.Running = false; }),
new MenuItem("_Cancel", "", () =>{ if (Quit("Cancel", CANCEL_TEXT)) _cancelled = true; top.Running = false; })
}
: new MenuItem []
{
new MenuItem("_Close", "", () =>{ if (Quit("Close", CLOSE_TEXT)) top.Running = false; })
})
});
top.Add(menu);
// add more stuff to win...
Application.Run();
This code is run within PowerShell (since you can write PowerShell cmdlets in C#)… so it’s code that gets run in the same .NET process over and over again.
On macOS and Linux, this code works as expected. I can launch it (and quit it) over and over again and it shows the display over and over again.
On Windows, the first time works, but the second time it hangs without any ability to kill what’s running:
Any ideas what might be happening here?
Issue Analytics
- State:
- Created 4 years ago
- Comments:32
Top Results From Across the Web
Restarting an application in the same process doesn't work ...
I can launch it (and quit it) over and over again and it shows the display over and over again. On Windows, the...
Read more >Programs not Opening unless restarted
Programs not Opening unless restarted · 1. Click the Start orb on your Desktop · 2. In the Start Search box. Type msconfig,...
Read more >Applications do not start again after having been shut down ...
There can be many reasons why the forcibly terminated apps aren't starting back up. Perhaps file locks have not been released yet by...
Read more >Why is my application is not starting up on Windows?
To kill the process, click on the process name, then select 'End Process' at the bottom of the window. After the process, you...
Read more >Restarting windows form application
i have a windows application C#4.0 with multithreadings problem is when i close the application ,the process stays on, no matter what i...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess there are a few commits after the release!
@BDisp ~That fixes the issue!!~ (See https://github.com/migueldeicaza/gui.cs/issues/339#issuecomment-596123402) Thanks for the pointer. I’ll ping @migueldeicaza on twitter to see if he could look at that PR.
That would enable Out-ConsoleGridView on Windows 😃
btw here’s the blog post: https://devblogs.microsoft.com/powershell/introducing-consoleguitools-preview/