Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Really fix 10s delay on Win10 #60

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions BrowseRouter/Actions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace BrowseRouter;

public static class Actions
{
public static bool TryRun(Action a)
{
try
{
a();
return true;
}
catch (Exception e)
{
Log.Write($"{e}");
return false;
}
}
}
9 changes: 7 additions & 2 deletions BrowseRouter/BrowserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ public async Task LaunchAsync(string url, string windowTitle)
Log.Write($"Launching {path} with args \"{args} {uri.OriginalString}\"");

string name = GetAppName(path);
await notifier.NotifyAsync($"Opening {name}", $"URL: {url}");

Process.Start(path, $"{args} \"{uri.OriginalString}\"");
if (!Actions.TryRun(() => Process.Start(path, $"{args} \"{uri.OriginalString}\"")))
{
await notifier.NotifyAsync($"Error", $"Could not open {name}. Please check the log for more details.");
return;
}

await notifier.NotifyAsync($"Opening {name}", $"URL: {url}");
}
catch (Exception e)
{
Expand Down
19 changes: 4 additions & 15 deletions BrowseRouter/DefaultBrowserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,9 @@ public async Task UnregisterAsync()
private void Unregister()
{
Log.Write("Unregistering...");
Try(() => Registry.CurrentUser.DeleteSubKeyTree(AppKey, false));
Try(() => _registerKey?.DeleteValue(_appID));
Try(() => Registry.CurrentUser.DeleteSubKeyTree(UrlKey));
Actions.TryRun(() => Registry.CurrentUser.DeleteSubKeyTree(AppKey, false));
Actions.TryRun(() => _registerKey?.DeleteValue(_appID));
Actions.TryRun(() => Registry.CurrentUser.DeleteSubKeyTree(UrlKey));
Log.Write("Done");
}

private static void Try(Action a)
{
try
{
a();
}
catch
{
}
}
}
}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>0.12.6</Version>
<Version>0.12.7</Version>
<Product>BrowseRouter</Product>
<Copyright>EnduraByte LLC 2024</Copyright>
<!-- Reduces flagging as malware -->
Expand Down
Loading