gpt4 book ai didi

c# - 在运行程序中执行方法而不是启动新实例

转载 作者:可可西里 更新时间:2023-11-01 13:27:23 26 4
gpt4 key购买 nike

我正在编写一个天气应用程序。我正在将它与任务栏集成。当您右键单击任务栏上的图标时,它会显示当前温度等。目前,如果您单击显示“当前:...”的文本,它会打开应用程序的另一个实例。

截图:

Weather taskbar

我怎样才能让它在我的程序中运行一个过程或函数?因此,如果用户单击“当前:...”,它应该在同一个应用程序中打开一个新表单。它不应该打开另一个应用程序吗?

我的代码目前是:

JumpListCustomCategory userActionsCategory = new JumpListCustomCategory("Weather");
userActionLink.Arguments = "-1";
JumpListLink userActionLink = new JumpListLink(Assembly.GetEntryAssembly().Location, Conditions + ": " + reader.ReadToEnd());
userActionLink.IconReference = new IconReference(testicon, 0);
userActionsCategory.AddJumpListItems(userActionLink);
list.AddCustomCategories(userActionsCategory);
list.Refresh();

最佳答案

看这里:The Weekly Source Code 31- Single Instance WinForms .它将允许您只打开一个程序实例,但使用 VisualBasic 而不是 Mutex。

关于c# - 在运行程序中执行方法而不是启动新实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12746975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com