+
Skip to content

Add RunWithSynchronizationContext with arguments #956

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

Merged
merged 2 commits into from
Sep 20, 2023
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
16 changes: 8 additions & 8 deletions src/Libs/Gio-2.0/Public/Application.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading;
using System;
using System.Threading;

namespace Gio;

Expand All @@ -9,20 +10,19 @@ static Application()
Module.Initialize();
}

public int Run()
{
return Internal.Application.Run(Handle, 0, new string[0]);
}

public int RunWithSynchronizationContext()
public int RunWithSynchronizationContext(string[]? args)
{
var original = SynchronizationContext.Current;

SynchronizationContext.SetSynchronizationContext(new GLib.Internal.MainLoopSynchronizationContext());

try
{
return Run();
if (args == null)
{
return Run(0, Array.Empty<string>());
}
return Run(args.Length, args);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion src/Samples/Adw-1/Window/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
window.SetChild(label);
window.Show();
};
return application.Run();
return application.RunWithSynchronizationContext(null);
2 changes: 1 addition & 1 deletion src/Samples/Gtk-4.0/AboutDialog/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
dialog.Show();
};

return application.Run();
return application.RunWithSynchronizationContext(null);
2 changes: 1 addition & 1 deletion src/Samples/Gtk-4.0/Builder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
dialog.OnResponse += (_, _) => application.Quit();
};

return application.Run();
return application.RunWithSynchronizationContext(null);
2 changes: 1 addition & 1 deletion src/Samples/Gtk-4.0/DrawingArea/DrawingArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ void Draw(Gtk.DrawingArea drawingArea, Cairo.Context cr, int width, int height)
cr.MoveTo(40, 60);
cr.ShowText("Powered by gir.core - GObject bindings for .NET");
}
return application.Run();
return application.RunWithSynchronizationContext(null);
2 changes: 1 addition & 1 deletion src/Samples/Gtk-4.0/Window/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
window.SetDefaultSize(300, 300);
window.Show();
};
return application.Run();
return application.RunWithSynchronizationContext(null);
2 changes: 1 addition & 1 deletion src/Samples/GtkSource-5/GtkSourceView/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
window.Child = view;
window.Show();
};
return application.Run();
return application.RunWithSynchronizationContext(null);
2 changes: 1 addition & 1 deletion src/Samples/WebKit-6.0/JavascriptCall/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
window.SetChild(webView);
window.Show();
};
return application.Run();
return application.RunWithSynchronizationContext(null);

#pragma warning restore CA1416
2 changes: 1 addition & 1 deletion src/Samples/WebKit-6.0/JavascriptCallback/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
window.SetChild(webView);
window.Present();
};
return application.Run();
return application.RunWithSynchronizationContext(null);

#pragma warning restore CA1416
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载