Skip to content

Commit

Permalink
MP1-5218: DeployTools: Transferring program installation to separate …
Browse files Browse the repository at this point in the history
…thread
  • Loading branch information
andrewjswan committed May 1, 2024
1 parent 96977e9 commit aad46b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public bool Install()
exitCode = Utils.RunCommandWait(InstallationProperties.Instance["DBMSDir"] + "\\bin\\mysqladmin.exe", cmdLine);
if (exitCode != 0)
{
MessageBox.Show("MariaDB - set password error: " + mysqladmin.ExitCode);
MessageBox.Show("MariaDB - set password error: " + exitCode);
return false;
}
}
Expand All @@ -294,7 +294,7 @@ public bool Install()
exitCode = Utils.RunCommandWait(InstallationProperties.Instance["DBMSDir"] + "\\bin\\mysql.exe", cmdLine);
if (exitCode != 0)
{
MessageBox.Show("MariaDB - set privileges error: " + mysql.ExitCode);
MessageBox.Show("MariaDB - set privileges error: " + exitCode);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public bool Install()
exitCode = Utils.RunCommandWait(InstallationProperties.Instance["DBMSDir"] + "\\bin\\mysqladmin.exe", cmdLine);
if (exitCode != 0)
{
MessageBox.Show("MySQL - set password error: " + mysqladmin.ExitCode);
MessageBox.Show("MySQL - set password error: " + exitCode);
return false;
}
}
Expand All @@ -369,7 +369,7 @@ public bool Install()
exitCode = Utils.RunCommandWait(InstallationProperties.Instance["DBMSDir"] + "\\bin\\mysql.exe", cmdLine);
if (exitCode != 0)
{
MessageBox.Show("MySQL - set privileges error: " + mysql.ExitCode);
MessageBox.Show("MySQL - set privileges error: " + exitCode);
return false;
}

Expand Down
12 changes: 9 additions & 3 deletions Tools/MediaPortal.DeployTool/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.IO;
using System.Resources;
using System.Globalization;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Diagnostics;
Expand Down Expand Up @@ -1021,14 +1022,19 @@ public static int RunCommand(string command, string arguments)
return -1;
}

public static async Task<int> RunCommandAsync(string command, string arguments)
public static Task<int> RunCommandAsync(string command, string arguments)
{
return await Task.Run(() => RunCommand(command, arguments));
return Task<int>.Factory.StartNew(() =>
{
return RunCommand(command, arguments);
});
}

public static int RunCommandWait(string command, string arguments)
{
return await RunCommandAsync(command, arguments);
Task<int> run = RunCommandAsync(command, arguments);
run.Wait();
return run.Result;
}

#endregion
Expand Down

0 comments on commit aad46b4

Please sign in to comment.