Friday, March 24, 2023

.NET Hot Reload

 .NET 6 Hot Reload in Visual Studio 2022, VS Code, and NOTEPAD?!? - YouTube

> dotnet new console

> dotnet run

hot reload:

> dotnet watch run 

// in implicit "Main" class and method, changes => hot reload changes pid
// Console.WriteLine($"Hello, World! pid: {System.Diagnostics.Process.GetCurrentProcess().Id}");

var u = new Utils();
while (true) {
    u.WritePid();
    Thread.Sleep(1000);
}

public class Utils { // changes => hot reload preserves pid!
    public void WritePid() {
        Console.WriteLine($"Hello, World! pid: {System.Diagnostics.Process.GetCurrentProcess().Id}");
    }
}



No comments: