Process requires disposal

This commit is contained in:
Chad Currie
2021-08-15 18:38:17 +12:00
parent 3c6efa6cb5
commit f934780300
3 changed files with 39 additions and 33 deletions

View File

@@ -906,7 +906,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
return -1;
}
var p = new Process
using (var p = new Process
{
StartInfo =
{
@@ -918,13 +918,15 @@ namespace Umbraco.Cms.Infrastructure.Persistence
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
}
};
p.Start();
output = p.StandardOutput.ReadToEnd();
error = p.StandardError.ReadToEnd();
p.WaitForExit();
})
{
p.Start();
output = p.StandardOutput.ReadToEnd();
error = p.StandardError.ReadToEnd();
p.WaitForExit();
return p.ExitCode;
return p.ExitCode;
}
}
/// <summary>

View File

@@ -72,15 +72,17 @@ namespace Umbraco.Cms.Infrastructure.Sync
GlobalSettings = globalSettings.Value;
_lastPruned = _lastSync = DateTime.UtcNow;
_syncIdle = new ManualResetEvent(true);
// See notes on _localIdentity
LocalIdentity = Environment.MachineName // eg DOMAIN\SERVER
+ "/" + hostingEnvironment.ApplicationId // eg /LM/S3SVC/11/ROOT
+ " [P" + Process.GetCurrentProcess().Id // eg 1234
+ "/D" + AppDomain.CurrentDomain.Id // eg 22
+ "] " + Guid.NewGuid().ToString("N").ToUpper(); // make it truly unique
using (var process = Process.GetCurrentProcess())
{
// See notes on _localIdentity
LocalIdentity = Environment.MachineName // eg DOMAIN\SERVER
+ "/" + hostingEnvironment.ApplicationId // eg /LM/S3SVC/11/ROOT
+ " [P" + process.Id // eg 1234
+ "/D" + AppDomain.CurrentDomain.Id // eg 22
+ "] " + Guid.NewGuid().ToString("N").ToUpper(); // make it truly unique
}
_initialized = new Lazy<SyncBootState?>(InitializeWithMainDom);
}
public GlobalSettings GlobalSettings { get; }